diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /xsd/tests/cxx/tree/encoding |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'xsd/tests/cxx/tree/encoding')
22 files changed, 791 insertions, 0 deletions
diff --git a/xsd/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx new file mode 100644 index 0000000..56b2df8 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/driver.cxx @@ -0,0 +1,76 @@ +// file : tests/cxx/tree/encoding/char/iso-8859-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 ISO-8859-1 encoding. +// + +#include <memory> // std::auto_ptr +#include <fstream> +#include <iostream> + +#include "test.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; + } + + try + { + try + { + root (argv[1]); + return 1; + } + catch (xsd::cxx::xml::iso8859_1_unrepresentable const&) + { + } + + xsd::cxx::xml::char_transcoder::unrep_char ('?'); + auto_ptr<type> r (root (argv[1])); + + { + type::a_sequence const& s (r->a ()); + + if (s[0] != "abc" || + s[1] != "\xE6" || + s[2] != "\xA2\xA3\xA4\xA5" || + s[3] != "???") + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a_c || + s[2] != strenum::cxx__bc) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map, "ISO-8859-1"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd/tests/cxx/tree/encoding/char/iso-8859-1/makefile b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/makefile new file mode 100644 index 0000000..967357f --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/encoding/char/iso-8859-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)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --char-encoding iso8859-1 --generate-serialization \ +--generate-doxygen +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) + +# 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)/xsd/tree/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.std b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.std new file mode 100644 index 0000000..ca6297f --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.std @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> +<t:root xmlns:t="test"> + + <a>abc</a> + + <a>æ</a> + + <a>¢£¤¥</a> + + <a>???</a> + + <b>abc</b> + + <b>aâc</b> + + <b>âòbc</b> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xml b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xml new file mode 100644 index 0000000..9c9e752 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xml @@ -0,0 +1,14 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <a>abc</a> + <a>æ</a> + <a>¢£¤¥</a> + <a>Āꪪ򪪪</a> + + <b>abc</b> + <b>aâc</b> + <b>âòbc</b> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd new file mode 100644 index 0000000..31b8901 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/iso-8859-1/test.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="strenum"> + + <annotation> + <documentation> + Test enum. Valid values are: + abc + aâc + òbc + </documentation> + </annotation> + + <restriction base="string"> + <enumeration value="abc"/> + <enumeration value="aâc"/> + <enumeration value="âòbc"/> + </restriction> + </simpleType> + + <complexType name="type"> + <sequence> + <element name="a" type="string" maxOccurs="unbounded"/> + <element name="b" type="t:strenum" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:type"/> + +</schema> diff --git a/xsd/tests/cxx/tree/encoding/char/lcp/driver.cxx b/xsd/tests/cxx/tree/encoding/char/lcp/driver.cxx new file mode 100644 index 0000000..2fb13a3 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/lcp/driver.cxx @@ -0,0 +1,42 @@ +// file : tests/cxx/tree/encoding/char/lcp/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 local code page encoding (--char-encoding lcp). +// The test just makes sure it still compiles and works. +// + +#include <memory> // std::auto_ptr +#include <fstream> +#include <iostream> + +#include "test.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; + } + + try + { + auto_ptr<type> r (root (argv[1])); + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd/tests/cxx/tree/encoding/char/lcp/makefile b/xsd/tests/cxx/tree/encoding/char/lcp/makefile new file mode 100644 index 0000000..518c514 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/lcp/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/encoding/char/lcp/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)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-serialization --char-encoding lcp +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) + +# 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)/xsd/tree/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/tests/cxx/tree/encoding/char/lcp/test.std b/xsd/tests/cxx/tree/encoding/char/lcp/test.std new file mode 100644 index 0000000..cc20ef7 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/lcp/test.std @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no" ?> +<t:root xmlns:t="test"> + + <a>abcd</a> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/char/lcp/test.xml b/xsd/tests/cxx/tree/encoding/char/lcp/test.xml new file mode 100644 index 0000000..772512e --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/lcp/test.xml @@ -0,0 +1,7 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <a>abcd</a> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/char/lcp/test.xsd b/xsd/tests/cxx/tree/encoding/char/lcp/test.xsd new file mode 100644 index 0000000..1e264e3 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/lcp/test.xsd @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <complexType name="type"> + <sequence> + <element name="a" type="string" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:type"/> + +</schema> diff --git a/xsd/tests/cxx/tree/encoding/char/makefile b/xsd/tests/cxx/tree/encoding/char/makefile new file mode 100644 index 0000000..3e64dd9 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/makefile @@ -0,0 +1,18 @@ +# file : tests/cxx/tree/encoding/char/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 + +tests := lcp utf-8 iso-8859-1 + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) + +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/xsd/tests/cxx/tree/encoding/char/utf-8/driver.cxx b/xsd/tests/cxx/tree/encoding/char/utf-8/driver.cxx new file mode 100644 index 0000000..0842203 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/utf-8/driver.cxx @@ -0,0 +1,67 @@ +// file : tests/cxx/tree/encoding/char/utf-8/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 UTF-8 encoding. +// + +#include <memory> // std::auto_ptr +#include <fstream> +#include <iostream> + +#include "test.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; + } + + try + { + auto_ptr<type> r (root (argv[1])); + + { + type::a_sequence const& s (r->a ()); + + if (s[0] != "abc" || + s[1] != "\xD5\x95" || + s[2] != "\xEA\xAA\xAA" || + s[3] != "\xF2\xAA\xAA\xAA") + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a_c || + s[2] != strenum::cxx_bc || + s[3] != strenum::ab_) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map["t"].name = "test"; + + root (std::cout, *r, map, "UCS-4LE"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd/tests/cxx/tree/encoding/char/utf-8/makefile b/xsd/tests/cxx/tree/encoding/char/utf-8/makefile new file mode 100644 index 0000000..8c0256e --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/utf-8/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/encoding/char/utf-8/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)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-serialization --generate-doxygen +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) + +# 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)/xsd/tree/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/tests/cxx/tree/encoding/char/utf-8/test.std b/xsd/tests/cxx/tree/encoding/char/utf-8/test.std Binary files differnew file mode 100644 index 0000000..328fe6d --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/utf-8/test.std diff --git a/xsd/tests/cxx/tree/encoding/char/utf-8/test.xml b/xsd/tests/cxx/tree/encoding/char/utf-8/test.xml new file mode 100644 index 0000000..a6e5d99 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/utf-8/test.xml @@ -0,0 +1,15 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <a>abc</a> + <a>Օ</a> + <a>ꪪ</a> + <a>򪪪</a> + + <b>abc</b> + <b>aՕc</b> + <b>ꪪbc</b> + <b>ab򪪪</b> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/char/utf-8/test.xsd b/xsd/tests/cxx/tree/encoding/char/utf-8/test.xsd new file mode 100644 index 0000000..6c32a32 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/char/utf-8/test.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="strenum"> + + <annotation> + <documentation> + Test enum. Valid values are: + abc + aՕc + ꪪbc + ab򪪪 + </documentation> + </annotation> + + <restriction base="string"> + <enumeration value="abc"/> + <enumeration value="aՕc"/> + <enumeration value="ꪪbc"/> + <enumeration value="ab򪪪"/> + </restriction> + </simpleType> + + <complexType name="type"> + <sequence> + <element name="a" type="string" maxOccurs="unbounded"/> + <element name="b" type="t:strenum" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:type"/> + +</schema> diff --git a/xsd/tests/cxx/tree/encoding/makefile b/xsd/tests/cxx/tree/encoding/makefile new file mode 100644 index 0000000..fcadb8c --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/makefile @@ -0,0 +1,18 @@ +# file : tests/cxx/tree/encoding/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 + +tests := char wchar + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) + +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/xsd/tests/cxx/tree/encoding/wchar/driver.cxx b/xsd/tests/cxx/tree/encoding/wchar/driver.cxx new file mode 100644 index 0000000..22cbfb4 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/wchar/driver.cxx @@ -0,0 +1,57 @@ +// file : tests/cxx/tree/encoding/wchar/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 the wide character mapping. +// + +#include <memory> // std::auto_ptr +#include <fstream> +#include <iostream> + +#include "test.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; + } + + try + { + // Use dont_validate because we do not have instance's system id (path). + // + std::ifstream ifs (argv[1]); + auto_ptr<type> r (root (ifs, xml_schema::flags::dont_validate)); + + { + type::b_sequence const& s (r->b ()); + + if (s[0] != strenum::abc || + s[1] != strenum::a__c || + s[2] != strenum::cxx__bc || + s[3] != strenum::ab__) + { + cerr << "invalid encoding" << endl; + return 1; + } + } + + xml_schema::namespace_infomap map; + map[L"t"].name = L"test"; + + root (std::cout, *r, map, L"UCS-4LE"); + } + catch (xml_schema::exception const& e) + { + cerr << "xml_schema::exception: " << e.what () << endl; + return 1; + } +} diff --git a/xsd/tests/cxx/tree/encoding/wchar/makefile b/xsd/tests/cxx/tree/encoding/wchar/makefile new file mode 100644 index 0000000..fb2faed --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/wchar/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/encoding/wchar/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)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +genf := $(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-serialization --generate-doxygen \ +--char-type wchar_t +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +$(out_base)/: $(driver) + + +# Test. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/test.std + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/test.std -,$(driver)) + +# 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)/xsd/tree/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/xsd/tests/cxx/tree/encoding/wchar/test.std b/xsd/tests/cxx/tree/encoding/wchar/test.std Binary files differnew file mode 100644 index 0000000..93d4561 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/wchar/test.std diff --git a/xsd/tests/cxx/tree/encoding/wchar/test.xml b/xsd/tests/cxx/tree/encoding/wchar/test.xml new file mode 100644 index 0000000..c6ec850 --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/wchar/test.xml @@ -0,0 +1,14 @@ +<t:root xmlns:t="test" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="test test.xsd"> + + <a>abc</a> + <a>῿퟿</a> + <a>𐀀􏿽</a> + + <b>abc</b> + <b>a῿퟿c</b> + <b>𐀀􏿽bc</b> + <b>ab𐀀􏿽</b> + +</t:root> diff --git a/xsd/tests/cxx/tree/encoding/wchar/test.xsd b/xsd/tests/cxx/tree/encoding/wchar/test.xsd new file mode 100644 index 0000000..0bf4bdd --- /dev/null +++ b/xsd/tests/cxx/tree/encoding/wchar/test.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="strenum"> + + <annotation> + <documentation> + Test enum. Valid values are: + abc + a῿퟿c + 𐀀􏿽bc + ab𐀀􏿽 + </documentation> + </annotation> + + <restriction base="string"> + <enumeration value="abc"/> + <enumeration value="a῿퟿c"/> + <enumeration value="𐀀􏿽bc"/> + <enumeration value="ab𐀀􏿽"/> + </restriction> + </simpleType> + + <complexType name="type"> + <sequence> + <element name="a" type="string" maxOccurs="unbounded"/> + <element name="b" type="t:strenum" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="root" type="t:type"/> + +</schema> |