aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-01-07 13:50:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-01-07 13:50:11 +0200
commit76d23e639004517db8f9469d64ac1789f8449365 (patch)
treedbafc8c4e31a97f74046c98af19d0fe76f360001 /tests
parentc30caae30bc64974eeaa1e81aa2abdc203f5120d (diff)
Add support for ISO-8859-1 as application encoding
New runtime configuration parameter, XSDE_ENCODING. New option, --char-encoding. New test, tests/cxx/hybrid/iso8859-1.
Diffstat (limited to 'tests')
-rw-r--r--tests/cxx/hybrid/iso8859-1/driver.cxx95
-rw-r--r--tests/cxx/hybrid/iso8859-1/makefile108
-rw-r--r--tests/cxx/hybrid/iso8859-1/test-000.std1
-rw-r--r--tests/cxx/hybrid/iso8859-1/test-000.xml15
-rw-r--r--tests/cxx/hybrid/iso8859-1/test.xsd23
-rw-r--r--tests/cxx/hybrid/makefile6
6 files changed, 247 insertions, 1 deletions
diff --git a/tests/cxx/hybrid/iso8859-1/driver.cxx b/tests/cxx/hybrid/iso8859-1/driver.cxx
new file mode 100644
index 0000000..ec68dbf
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/driver.cxx
@@ -0,0 +1,95 @@
+// file : tests/cxx/hybrid/iso8859-1/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test support for the ISO-8859-1 encoding.
+//
+
+#include <assert.h>
+
+#include <string>
+#include <iostream>
+
+#include "test.hxx"
+#include "test-pimpl.hxx"
+#include "test-simpl.hxx"
+
+#include <xsde/cxx/iso8859-1.hxx>
+
+using namespace std;
+using namespace test;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " test.xml" << endl;
+ return 1;
+ }
+
+ // Parse.
+ //
+ root_paggr root_p;
+
+ xml_schema::document_pimpl doc_p (
+ root_p.root_parser (),
+ root_p.root_namespace (),
+ root_p.root_name ());
+
+#ifdef XSDE_EXCEPTIONS
+ try
+ {
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+ assert (false);
+ }
+ catch (const xml_schema::parser_exception& e)
+ {
+ // cerr << e.line () << ":" << e.column () << ": " << e.text () << endl;
+ }
+#else
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ assert (doc_p._error ());
+#endif
+
+ doc_p.reset ();
+ xml_schema::iso8859_1::unrep_char ('?');
+
+ root_p.pre ();
+ doc_p.parse (argv[1]);
+ type* r = root_p.post ();
+
+ assert (r->a ()[0] == string ("abc"));
+ assert (r->a ()[1] == string ("\xE6"));
+ assert (r->a ()[2] == string ("\xA2\xA3\xA4\xA5"));
+ assert (r->a ()[3] == string ("???"));
+ assert (r->a ()[4] == string ("longlonglonglonglonglonglonglonglonglonglonglong\xE6longlonglonglong"));
+
+ assert (r->b ()[0] == strenum::abc);
+ assert (r->b ()[1] == strenum::a_c);
+ assert (r->b ()[1].string () == string ("a\xE2""c"));
+ assert (r->b ()[2] == strenum::cxx__bc);
+
+ assert (r->element_name_with_special_char__ () == string ("longlonglong\xA2\xA3\xA4\xA5longlong"));
+
+ // Serialize.
+ //
+ root_saggr root_s;
+
+ xml_schema::document_simpl doc_s (
+ root_s.root_serializer (),
+ root_s.root_namespace (),
+ root_s.root_name ());
+
+ doc_s.add_prefix ("t", "test");
+
+ root_s.pre (*r);
+ doc_s.serialize (cout);
+ root_s.post ();
+
+ delete r;
+}
diff --git a/tests/cxx/hybrid/iso8859-1/makefile b/tests/cxx/hybrid/iso8859-1/makefile
new file mode 100644
index 0000000..2cc1f57
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/makefile
@@ -0,0 +1,108 @@
+# file : tests/cxx/hybrid/iso8859-1/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC
+# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
+
+xsd := test.xsd
+cxx := driver.cxx
+
+obj := $(addprefix $(out_base)/,\
+$(cxx:.cxx=.o) \
+$(xsd:.xsd=.o) \
+$(xsd:.xsd=-pskel.o) \
+$(xsd:.xsd=-pimpl.o) \
+$(xsd:.xsd=-sskel.o) \
+$(xsd:.xsd=-simpl.o))
+
+dep := $(obj:.o=.o.d)
+
+xsde.l := $(out_root)/libxsde/xsde/xsde.l
+xsde.l.cpp-options := $(out_root)/libxsde/xsde/xsde.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+dist := $(out_base)/.dist
+dist-win := $(out_base)/.dist-win
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(obj) $(xsde.l)
+
+$(obj) $(dep): $(xsde.l.cpp-options)
+
+genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.cxx) \
+ $(xsd:.xsd=-pskel.hxx) $(xsd:.xsd=-pskel.cxx) \
+ $(xsd:.xsd=-pimpl.hxx) $(xsd:.xsd=-pimpl.cxx) \
+ $(xsd:.xsd=-sskel.hxx) $(xsd:.xsd=-sskel.cxx) \
+ $(xsd:.xsd=-simpl.hxx) $(xsd:.xsd=-simpl.cxx)
+
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(out_root)/xsde/xsde
+$(gen): xsde := $(out_root)/xsde/xsde
+$(gen) $(dist) $(dist-win): xsde_options += --generate-parser \
+--generate-serializer --generate-aggregate
+
+$(call include-dep,$(dep))
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/test-000.xml $(src_base)/test-000.std
+ $(call message,test $$1,$$1 $(src_base)/test-000.xml | diff -u $(src_base)/test-000.std -,$(driver))
+
+
+# Dist.
+#
+$(dist) $(dist-win): opt := -src $(src_base) -cmd cxx-hybrid -xsd "$(xsd)" \
+-cxx "$(cxx)" -gen "$(genf)" -opt "$(xsde_options)" -out $(dist_prefix)
+
+$(dist):
+ $(call message,install $(src_base),$(scf_root)/dist $(opt))
+
+$(dist-win):
+ $(call message,install $(src_base),$(scf_root)/dist -win $(opt))
+
+
+# Clean.
+#
+$(clean): $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(obj)) \
+ $(addsuffix .cxx.clean,$(dep)) \
+ $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean))
+
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(gen): | $(out_base)/.gitignore
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-e.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(scf_root)/xsde/hybrid/xsd-cxx.make)
+
+
+# Dependencies.
+#
+$(call import,$(src_root)/xsde/makefile)
+$(call import,$(src_root)/libxsde/xsde/makefile)
diff --git a/tests/cxx/hybrid/iso8859-1/test-000.std b/tests/cxx/hybrid/iso8859-1/test-000.std
new file mode 100644
index 0000000..2631b99
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test-000.std
@@ -0,0 +1 @@
+<t:root xmlns:t="test" x="longlonglong¢£¤¥longlong"><a>abc</a><a>æ</a><a>¢£¤¥</a><a>???</a><a>longlonglonglonglonglonglonglonglonglonglonglongælonglonglonglong</a><b>abc</b><b>aâc</b><b>âòbc</b><element_name_with_special_char_â>longlonglong¢£¤¥longlong</element_name_with_special_char_â></t:root> \ No newline at end of file
diff --git a/tests/cxx/hybrid/iso8859-1/test-000.xml b/tests/cxx/hybrid/iso8859-1/test-000.xml
new file mode 100644
index 0000000..fd61446
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test-000.xml
@@ -0,0 +1,15 @@
+<t:root xmlns:t="test" x="longlonglong&#xA2;&#xA3;&#xA4;&#xA5;longlong">
+
+ <a>abc</a>
+ <a>&#xE6;</a>
+ <a>&#xA2;&#xA3;&#xA4;&#xA5;</a>
+ <a>&#x100;&#xAAAA;&#xAAAAA;</a>
+ <a>longlonglonglonglonglonglonglonglonglonglonglong&#xE6;longlonglonglong</a>
+
+ <b>abc</b>
+ <b>a&#xE2;c</b>
+ <b>&#xE2;&#xF2;bc</b>
+
+ <element_name_with_special_char_â>longlonglong&#xA2;&#xA3;&#xA4;&#xA5;longlong</element_name_with_special_char_â>
+
+</t:root>
diff --git a/tests/cxx/hybrid/iso8859-1/test.xsd b/tests/cxx/hybrid/iso8859-1/test.xsd
new file mode 100644
index 0000000..242b84a
--- /dev/null
+++ b/tests/cxx/hybrid/iso8859-1/test.xsd
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test">
+
+ <simpleType name="strenum">
+ <restriction base="string">
+ <enumeration value="abc"/>
+ <enumeration value="a&#xE2;c"/>
+ <enumeration value="&#xE2;&#xF2;bc"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="type">
+ <sequence>
+ <element name="a" type="string" maxOccurs="unbounded"/>
+ <element name="b" type="t:strenum" maxOccurs="unbounded"/>
+ <element name="element_name_with_special_char_&#xE2;" type="string"/>
+ </sequence>
+ <attribute name="x" type="string"/>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
diff --git a/tests/cxx/hybrid/makefile b/tests/cxx/hybrid/makefile
index 60960c3..8fb3f3f 100644
--- a/tests/cxx/hybrid/makefile
+++ b/tests/cxx/hybrid/makefile
@@ -10,7 +10,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
#
all_tests := sequences polymorphism iterator built-in default enumeration \
-list recursive test-template union binary/cdr binary/xdr choice
+iso8859-1 list recursive test-template union binary/cdr binary/xdr choice
build_tests := sequences
@@ -27,6 +27,10 @@ endif
ifeq ($(xsde_iostream),y)
build_tests += built-in default enumeration list test-template union
+ifeq ($(xsde_encoding),iso8859-1)
+build_tests += iso8859-1
+endif
+
ifeq ($(xsde_cdr),y)
build_tests += binary/cdr
endif