diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-18 18:48:46 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-02-25 13:45:48 +0300 |
commit | 5e527213a2430bb3018e5eebd909aef294edf9b5 (patch) | |
tree | 94de33c82080b53d9a9e300170f6d221d89078f4 /libxsd-tests | |
parent | 7420f85ea19b0562ffdd8123442f32bc8bac1267 (diff) |
Switch to build2
Diffstat (limited to 'libxsd-tests')
-rw-r--r-- | libxsd-tests/.gitignore | 28 | ||||
l--------- | libxsd-tests/FLOSSE | 1 | ||||
l--------- | libxsd-tests/GPLv2 | 1 | ||||
l--------- | libxsd-tests/LICENSE | 1 | ||||
-rw-r--r-- | libxsd-tests/README | 8 | ||||
-rw-r--r-- | libxsd-tests/build/.gitignore | 3 | ||||
-rw-r--r-- | libxsd-tests/build/bootstrap.build | 9 | ||||
-rw-r--r-- | libxsd-tests/build/root.build | 25 | ||||
-rw-r--r-- | libxsd-tests/buildfile | 4 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/expat/basic/buildfile | 7 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/expat/basic/driver.cxx | 124 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/expat/basic/testscript | 41 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/xerces/basic/buildfile | 7 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/xerces/basic/driver.cxx | 124 | ||||
-rw-r--r-- | libxsd-tests/cxx/parser/xerces/basic/testscript | 41 | ||||
-rw-r--r-- | libxsd-tests/cxx/tree/basic/buildfile | 7 | ||||
-rw-r--r-- | libxsd-tests/cxx/tree/basic/driver.cxx | 65 | ||||
-rw-r--r-- | libxsd-tests/cxx/tree/basic/testscript | 73 | ||||
-rw-r--r-- | libxsd-tests/manifest | 15 |
19 files changed, 584 insertions, 0 deletions
diff --git a/libxsd-tests/.gitignore b/libxsd-tests/.gitignore new file mode 100644 index 0000000..1b1f9fb --- /dev/null +++ b/libxsd-tests/.gitignore @@ -0,0 +1,28 @@ +# Compiler/linker output. +# +*.d +*.t +*.i +*.ii +*.o +*.obj +*.so +*.dll +*.a +*.lib +*.exp +*.pdb +*.ilk +*.exe +*.exe.dlls/ +*.exe.manifest +*.pc + +# Test executables. +# +driver + +# Testscript output directories (can be symlinks). +# +test +test-* diff --git a/libxsd-tests/FLOSSE b/libxsd-tests/FLOSSE new file mode 120000 index 0000000..be6df3d --- /dev/null +++ b/libxsd-tests/FLOSSE @@ -0,0 +1 @@ +../FLOSSE
\ No newline at end of file diff --git a/libxsd-tests/GPLv2 b/libxsd-tests/GPLv2 new file mode 120000 index 0000000..08e5586 --- /dev/null +++ b/libxsd-tests/GPLv2 @@ -0,0 +1 @@ +../GPLv2
\ No newline at end of file diff --git a/libxsd-tests/LICENSE b/libxsd-tests/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/libxsd-tests/LICENSE @@ -0,0 +1 @@ +../LICENSE
\ No newline at end of file diff --git a/libxsd-tests/README b/libxsd-tests/README new file mode 100644 index 0000000..1ab33da --- /dev/null +++ b/libxsd-tests/README @@ -0,0 +1,8 @@ +This package contains tests for the XSD to C++ data binding runtime library. + +See the LICENSE file for distribution conditions. + +The project page is at https://www.codesynthesis.com/projects/xsd/. + +Send bug reports or any other feedback to the xsd-users@codesynthesis.com +mailing list. diff --git a/libxsd-tests/build/.gitignore b/libxsd-tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/libxsd-tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/libxsd-tests/build/bootstrap.build b/libxsd-tests/build/bootstrap.build new file mode 100644 index 0000000..e10dbfc --- /dev/null +++ b/libxsd-tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : build/bootstrap.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +project = libxsd-tests + +using version +using config +using dist +using test diff --git a/libxsd-tests/build/root.build b/libxsd-tests/build/root.build new file mode 100644 index 0000000..d511eb2 --- /dev/null +++ b/libxsd-tests/build/root.build @@ -0,0 +1,25 @@ +# file : build/root.build +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +cxx.std = latest + +using cxx + +hxx{*}: extension = hxx +ixx{*}: extension = ixx +txx{*}: extension = txx +cxx{*}: extension = cxx + +if ($cxx.target.system == 'win32-msvc') + cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + +if ($cxx.class == 'msvc') + cxx.coptions += /wd4251 /wd4275 /wd4800 + +# Every exe{} in this project is by default a test. +# +exe{*}: test = true + +# Specify the test target for cross-testing. +# +test.target = $cxx.target diff --git a/libxsd-tests/buildfile b/libxsd-tests/buildfile new file mode 100644 index 0000000..e783791 --- /dev/null +++ b/libxsd-tests/buildfile @@ -0,0 +1,4 @@ +# file : buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +./: {*/ -build/} doc{README} legal{GPLv2 LICENSE FLOSSE} manifest diff --git a/libxsd-tests/cxx/parser/expat/basic/buildfile b/libxsd-tests/cxx/parser/expat/basic/buildfile new file mode 100644 index 0000000..86279d4 --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/parser/expat/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libexpat%lib{expat} + +exe{driver}: cxx{driver} $libs testscript diff --git a/libxsd-tests/cxx/parser/expat/basic/driver.cxx b/libxsd-tests/cxx/parser/expat/basic/driver.cxx new file mode 100644 index 0000000..f601e7a --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/parser/expat/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cassert> +#include <iostream> + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include <xsd/cxx/config.hxx> // XSD_UNUSED +#include <xsd/cxx/ro-string.hxx> + +#include <xsd/cxx/parser/expat/elements.hxx> + +#include <xsd/cxx/parser/non-validating/parser.hxx> +#include <xsd/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx> + +using namespace std; +using namespace xsd::cxx; + +typedef parser::non_validating::string_pskel<char> string_pskel; + +class hello_pimpl: public parser::non_validating::complex_content<char> +{ +public: + hello_pimpl (string_pskel& greeting, string_pskel& name) + : greeting_parser_ (&greeting), + name_parser_ (&name) {} + +private: + virtual bool + _start_element_impl (const ro_string<char>&, + const ro_string<char>&, + const ro_string<char>*); + + virtual bool + _end_element_impl (const ro_string<char>&, const ro_string<char>&); + + string_pskel* greeting_parser_; + string_pskel* name_parser_; +}; + +bool hello_pimpl:: +_start_element_impl (const ro_string<char>& ns, + const ro_string<char>& n, + const ro_string<char>* t) +{ + XSD_UNUSED (t); + + if (complex_content::_start_element_impl (ns, n, t)) + return true; + + if (n == "greeting" && ns.empty ()) + { + context_.top ().parser_ = greeting_parser_; + + if (greeting_parser_) + greeting_parser_->pre (); + + return true; + } + + if (n == "name" && ns.empty ()) + { + context_.top ().parser_ = name_parser_; + + if (name_parser_) + name_parser_->pre (); + + return true; + } + + return false; +} + +bool hello_pimpl:: +_end_element_impl (const ro_string<char>& ns, const ro_string<char>& n) +{ + if (complex_content::_end_element_impl (ns, n)) + return true; + + if (n == "greeting" && ns.empty ()) + { + cout << n << ' ' << greeting_parser_->post_string () << endl; + return true; + } + + if (n == "name" && ns.empty ()) + { + cout << n << ' ' << name_parser_->post_string () << endl; + return true; + } + + return false; +} + + +// Usage: argv[0] <xml-file> +// +// Parse the specified XML file using the event-driven skeleton-based parser +// and print the element names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + parser::non_validating::string_pimpl<char> string_p; + hello_pimpl hello_p (string_p, string_p); + + parser::expat::document<char> doc_p (hello_p, "hello"); + + doc_p.parse (argv[1]); +} diff --git a/libxsd-tests/cxx/parser/expat/basic/testscript b/libxsd-tests/cxx/parser/expat/basic/testscript new file mode 100644 index 0000000..7e78e73 --- /dev/null +++ b/libxsd-tests/cxx/parser/expat/basic/testscript @@ -0,0 +1,41 @@ +# file : cxx/parser/expat/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <<EOI >=hello.xsd; + <?xml version="1.0"?> + <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:complexType name="hello"> + <xsd:sequence> + <xsd:element name="greeting" type="xsd:string"/> + <xsd:element name="name" type="xsd:string" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="hello" type="hello"/> + </xsd:schema> + EOI + + cat <<EOI >=hello.xml; + <?xml version="1.0"?> + <hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + </hello> + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/cxx/parser/xerces/basic/buildfile b/libxsd-tests/cxx/parser/xerces/basic/buildfile new file mode 100644 index 0000000..237629d --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/parser/xerces/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: cxx{driver} $libs testscript diff --git a/libxsd-tests/cxx/parser/xerces/basic/driver.cxx b/libxsd-tests/cxx/parser/xerces/basic/driver.cxx new file mode 100644 index 0000000..b7dfd1d --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/driver.cxx @@ -0,0 +1,124 @@ +// file : cxx/parser/xerces/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cassert> +#include <iostream> + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include <xsd/cxx/config.hxx> // XSD_UNUSED +#include <xsd/cxx/ro-string.hxx> + +#include <xsd/cxx/parser/xerces/elements.hxx> + +#include <xsd/cxx/parser/non-validating/parser.hxx> +#include <xsd/cxx/parser/non-validating/xml-schema-pskel.hxx> +#include <xsd/cxx/parser/non-validating/xml-schema-pimpl.hxx> + +using namespace std; +using namespace xsd::cxx; + +typedef parser::non_validating::string_pskel<char> string_pskel; + +class hello_pimpl: public parser::non_validating::complex_content<char> +{ +public: + hello_pimpl (string_pskel& greeting, string_pskel& name) + : greeting_parser_ (&greeting), + name_parser_ (&name) {} + +private: + virtual bool + _start_element_impl (const ro_string<char>&, + const ro_string<char>&, + const ro_string<char>*); + + virtual bool + _end_element_impl (const ro_string<char>&, const ro_string<char>&); + + string_pskel* greeting_parser_; + string_pskel* name_parser_; +}; + +bool hello_pimpl:: +_start_element_impl (const ro_string<char>& ns, + const ro_string<char>& n, + const ro_string<char>* t) +{ + XSD_UNUSED (t); + + if (complex_content::_start_element_impl (ns, n, t)) + return true; + + if (n == "greeting" && ns.empty ()) + { + context_.top ().parser_ = greeting_parser_; + + if (greeting_parser_) + greeting_parser_->pre (); + + return true; + } + + if (n == "name" && ns.empty ()) + { + context_.top ().parser_ = name_parser_; + + if (name_parser_) + name_parser_->pre (); + + return true; + } + + return false; +} + +bool hello_pimpl:: +_end_element_impl (const ro_string<char>& ns, const ro_string<char>& n) +{ + if (complex_content::_end_element_impl (ns, n)) + return true; + + if (n == "greeting" && ns.empty ()) + { + cout << n << ' ' << greeting_parser_->post_string () << endl; + return true; + } + + if (n == "name" && ns.empty ()) + { + cout << n << ' ' << name_parser_->post_string () << endl; + return true; + } + + return false; +} + + +// Usage: argv[0] <xml-file> +// +// Parse the specified XML file using the event-driven skeleton-based parser +// and print the element names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + parser::non_validating::string_pimpl<char> string_p; + hello_pimpl hello_p (string_p, string_p); + + parser::xerces::document<char> doc_p (hello_p, "hello"); + + doc_p.parse (argv[1]); +} diff --git a/libxsd-tests/cxx/parser/xerces/basic/testscript b/libxsd-tests/cxx/parser/xerces/basic/testscript new file mode 100644 index 0000000..f11fb10 --- /dev/null +++ b/libxsd-tests/cxx/parser/xerces/basic/testscript @@ -0,0 +1,41 @@ +# file : cxx/parser/xerces/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <<EOI >=hello.xsd; + <?xml version="1.0"?> + <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:complexType name="hello"> + <xsd:sequence> + <xsd:element name="greeting" type="xsd:string"/> + <xsd:element name="name" type="xsd:string" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="hello" type="hello"/> + </xsd:schema> + EOI + + cat <<EOI >=hello.xml; + <?xml version="1.0"?> + <hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + </hello> + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/cxx/tree/basic/buildfile b/libxsd-tests/cxx/tree/basic/buildfile new file mode 100644 index 0000000..1bf94b0 --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/buildfile @@ -0,0 +1,7 @@ +# file : cxx/tree/basic/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{*} $libs testscript diff --git a/libxsd-tests/cxx/tree/basic/driver.cxx b/libxsd-tests/cxx/tree/basic/driver.cxx new file mode 100644 index 0000000..d36d31e --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/driver.cxx @@ -0,0 +1,65 @@ +// file : cxx/tree/basic/driver.cxx +// copyright : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cassert> +#include <iostream> + +#include <xercesc/dom/DOMText.hpp> +#include <xercesc/dom/DOMElement.hpp> +#include <xercesc/dom/DOMDocument.hpp> + +// Define XSD_CXX11 since we include libxsd headers directly. +// +#ifdef _MSC_VER +# if _MSC_VER >= 1600 // VC++10 and later have C++11 always enabled. +# define XSD_CXX11 +# endif +#else +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define XSD_CXX11 +# endif +#endif + +#include <xsd/cxx/xml/qualified-name.hxx> + +#include <xsd/cxx/xml/dom/auto-ptr.hxx> // XSD_DOM_AUTO_PTR +#include <xsd/cxx/xml/dom/elements.hxx> // name() +#include <xsd/cxx/xml/dom/parsing-source.hxx> // parser, parse() + +#include <xsd/cxx/tree/text.hxx> // text_content() +#include <xsd/cxx/tree/parsing.hxx> +#include <xsd/cxx/tree/elements.hxx> // auto_initializer, properties +#include <xsd/cxx/tree/exceptions.hxx> // parsing +#include <xsd/cxx/tree/error-handler.hxx> + +using namespace std; +using namespace xsd::cxx; + +// Usage: argv[0] <xml-file> +// +// Parse the specified XML file using the XML DOM parser and print the element +// names and values to stdout. +// +int +main (int argc, char* argv[]) +{ + assert (argc == 2); + + xml::auto_initializer ai; + + tree::error_handler<char> h; + tree::properties<char> ps; + + XSD_DOM_AUTO_PTR<xercesc::DOMDocument> d ( + xml::dom::parse<char> (argv[1], h, ps, 0 /* flags */)); + + h.throw_if_failed<tree::parsing<char>> (); // Abort on error. + + xml::dom::parser<char> p (*d->getDocumentElement (), true, false, false); + for (; p.more_content (); p.next_content (false /* text */)) + { + const xercesc::DOMElement& i (p.cur_element ()); + const xml::qualified_name<char> n (xml::dom::name<char> (i)); + cout << n.name () << ' ' << tree::text_content<char> (i) << endl; + } +} diff --git a/libxsd-tests/cxx/tree/basic/testscript b/libxsd-tests/cxx/tree/basic/testscript new file mode 100644 index 0000000..2606688 --- /dev/null +++ b/libxsd-tests/cxx/tree/basic/testscript @@ -0,0 +1,73 @@ +# file : cxx/tree/basic/testscript +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +: basic +: +{ + cat <<EOI >=hello.xsd; + <?xml version="1.0"?> + <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:complexType name="hello_t"> + + <xsd:annotation> + <xsd:documentation> + The hello_t type consists of a greeting phrase and a + collection of names to which this greeting applies. + </xsd:documentation> + </xsd:annotation> + + <xsd:sequence> + + <xsd:element name="greeting" type="xsd:string"> + <xsd:annotation> + <xsd:documentation> + The greeting element contains the greeting phrase + for this hello object. + </xsd:documentation> + </xsd:annotation> + </xsd:element> + + <xsd:element name="name" type="xsd:string" maxOccurs="unbounded"> + <xsd:annotation> + <xsd:documentation> + The name elements contains names to be greeted. + </xsd:documentation> + </xsd:annotation> + </xsd:element> + + </xsd:sequence> + </xsd:complexType> + + <xsd:element name="hello" type="hello_t"> + <xsd:annotation> + <xsd:documentation> + The hello element is a root of the Hello XML vocabulary. + Every conforming document should start with this element. + </xsd:documentation> + </xsd:annotation> + </xsd:element> + </xsd:schema> + EOI + + cat <<EOI >=hello.xml; + <?xml version="1.0"?> + <hello xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="hello.xsd"> + + <greeting>Hello</greeting> + + <name>sun</name> + <name>moon</name> + <name>world</name> + + </hello> + EOI + + $* hello.xml >>EOO + greeting Hello + name sun + name moon + name world + EOO +} diff --git a/libxsd-tests/manifest b/libxsd-tests/manifest new file mode 100644 index 0000000..8de8b24 --- /dev/null +++ b/libxsd-tests/manifest @@ -0,0 +1,15 @@ +: 1 +name: libxsd-tests +version: 4.2.0-b.1.z +project: xsd +summary: XML Schema to C++ data binding compiler runtime library tests +license: other: GPL-2.0-only with Xerces-C++ linking exception and FLOSS exception +description-file: README +url: https://www.codesynthesis.com/projects/xsd/ +doc-url: https://www.codesynthesis.com/projects/xsd/ +src-url: https://git.codesynthesis.com/cgit/xsd/xsd/tree/libxsd-tests/ +email: xsd-users@codesynthesis.com ; Mailing list +depends: * build2 >= 0.13.0 +depends: * bpkg >= 0.13.0 +depends: libxerces-c ^3.0.0 +depends: libexpat ^2.1.0 |