From 5e527213a2430bb3018e5eebd909aef294edf9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- xsd-tests/cxx/parser/enumeration/buildfile | 24 +++++++++ xsd-tests/cxx/parser/enumeration/driver.cxx | 81 +++++++++++++++++++++++++++++ xsd-tests/cxx/parser/enumeration/gender.hxx | 13 +++++ xsd-tests/cxx/parser/enumeration/output | 3 ++ xsd-tests/cxx/parser/enumeration/test.map | 7 +++ xsd-tests/cxx/parser/enumeration/test.xml | 10 ++++ xsd-tests/cxx/parser/enumeration/test.xsd | 35 +++++++++++++ 7 files changed, 173 insertions(+) create mode 100644 xsd-tests/cxx/parser/enumeration/buildfile create mode 100644 xsd-tests/cxx/parser/enumeration/driver.cxx create mode 100644 xsd-tests/cxx/parser/enumeration/gender.hxx create mode 100644 xsd-tests/cxx/parser/enumeration/output create mode 100644 xsd-tests/cxx/parser/enumeration/test.map create mode 100644 xsd-tests/cxx/parser/enumeration/test.xml create mode 100644 xsd-tests/cxx/parser/enumeration/test.xsd (limited to 'xsd-tests/cxx/parser/enumeration') diff --git a/xsd-tests/cxx/parser/enumeration/buildfile b/xsd-tests/cxx/parser/enumeration/buildfile new file mode 100644 index 0000000..05163df --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/enumeration/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}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} map{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --type-map $path($<[1]) \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" "-I$src_base" diff --git a/xsd-tests/cxx/parser/enumeration/driver.cxx b/xsd-tests/cxx/parser/enumeration/driver.cxx new file mode 100644 index 0000000..4776ee2 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/driver.cxx @@ -0,0 +1,81 @@ +// file : cxx/parser/enumeration/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:enumeration parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace xml_schema; + +struct digit_pimpl: test::digit_pskel, int_pimpl +{ +}; + +struct gender_pimpl: test::gender_pskel, string_pimpl +{ + virtual ::gender + post_gender () + { + std::string str (post_string ()); + + if (str == "male") + return male; + else + return female; + } +}; + +struct type_pimpl: test::type_pskel +{ + virtual void + digit (int i) + { + cout << i << endl; + } + + virtual void + gender (::gender g) + { + cout << g << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + digit_pimpl digit_p; + gender_pimpl gender_p; + type_pimpl type_p; + + type_p.parsers (digit_p, gender_p); + + document doc_p (type_p, "test", "root"); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/enumeration/gender.hxx b/xsd-tests/cxx/parser/enumeration/gender.hxx new file mode 100644 index 0000000..a2e5cd8 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/gender.hxx @@ -0,0 +1,13 @@ +// file : tests/cxx/parser/enumeration/gender.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef GENDER_HXX +#define GENDER_HXX + +enum gender +{ + male, + female +}; + +#endif // GENDER_HXX diff --git a/xsd-tests/cxx/parser/enumeration/output b/xsd-tests/cxx/parser/enumeration/output new file mode 100644 index 0000000..16db301 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/output @@ -0,0 +1,3 @@ +1 +0 +1 diff --git a/xsd-tests/cxx/parser/enumeration/test.map b/xsd-tests/cxx/parser/enumeration/test.map new file mode 100644 index 0000000..f8868d6 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.map @@ -0,0 +1,7 @@ +namespace test +{ + include "gender.hxx"; + + digit int int; + gender ::gender ::gender; +} diff --git a/xsd-tests/cxx/parser/enumeration/test.xml b/xsd-tests/cxx/parser/enumeration/test.xml new file mode 100644 index 0000000..a6fa893 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xml @@ -0,0 +1,10 @@ + + + 1 + + male + female + + diff --git a/xsd-tests/cxx/parser/enumeration/test.xsd b/xsd-tests/cxx/parser/enumeration/test.xsd new file mode 100644 index 0000000..ded3a18 --- /dev/null +++ b/xsd-tests/cxx/parser/enumeration/test.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1