summaryrefslogtreecommitdiff
path: root/tests/cxx/tree/built-in/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-17 07:15:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-17 07:15:29 +0200
commitf0510d2f90467de8e8f260b47d79a9baaf9bef17 (patch)
tree0b9929946f06a9cbe9b9e8f2a7600dae4e048f79 /tests/cxx/tree/built-in/driver.cxx
Start tracking XSD with git
Diffstat (limited to 'tests/cxx/tree/built-in/driver.cxx')
-rw-r--r--tests/cxx/tree/built-in/driver.cxx94
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/cxx/tree/built-in/driver.cxx b/tests/cxx/tree/built-in/driver.cxx
new file mode 100644
index 0000000..f3138aa
--- /dev/null
+++ b/tests/cxx/tree/built-in/driver.cxx
@@ -0,0 +1,94 @@
+// file : tests/cxx/tree/built-in/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+// Test built-in type mapping.
+//
+
+#include <memory> // std::auto_ptr
+#include <sstream>
+#include <iostream>
+
+
+#include "types.hxx"
+
+using std::cerr;
+using std::endl;
+using std::auto_ptr;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 4)
+ {
+ cerr << "usage: " << argv[0] << " elements.xml attributes.xml inherited.xml" << endl;
+ return 1;
+ }
+
+ auto_ptr<xmlns::test::Elements> elements (xmlns::test::elements (argv[1]));
+
+ auto_ptr<xmlns::test::Attributes> attributes (
+ xmlns::test::attributes (argv[2]));
+
+ auto_ptr<xmlns::test::Inherited> inherited (
+ xmlns::test::inherited (argv[3]));
+
+ cerr << "elements: " << *elements << endl
+ << endl
+ << "attributes: " << *attributes << endl
+ << endl
+ << "inherited: " << *inherited << endl;
+
+ // Test parsing/serialization.
+ //
+
+ xml_schema::namespace_infomap map;
+
+ map["test"].name = "http://www.codesynthesis.com/xmlns/test";
+ map["test"].schema = "types.xsd";
+
+ {
+ std::ostringstream ostr;
+ xmlns::test::elements (ostr, *elements, map);
+
+ std::istringstream istr (ostr.str ());
+ auto_ptr<xmlns::test::Elements> elements1 (xmlns::test::elements (istr));
+
+ std::ostringstream ostr1;
+ xmlns::test::elements (ostr1, *elements1, map);
+
+ if (ostr.str () != ostr1.str ())
+ return 1;
+ }
+
+ {
+ std::ostringstream ostr;
+ xmlns::test::attributes (ostr, *attributes, map);
+
+ std::istringstream istr (ostr.str ());
+ auto_ptr<xmlns::test::Attributes> attributes1 (
+ xmlns::test::attributes (istr));
+
+ std::ostringstream ostr1;
+ xmlns::test::attributes (ostr1, *attributes1, map);
+
+ if (ostr.str () != ostr1.str ())
+ return 1;
+ }
+
+ {
+ std::ostringstream ostr;
+ xmlns::test::inherited (ostr, *inherited, map);
+
+ std::istringstream istr (ostr.str ());
+ auto_ptr<xmlns::test::Inherited> inherited1 (
+ xmlns::test::inherited (istr));
+
+ std::ostringstream ostr1;
+ xmlns::test::inherited (ostr1, *inherited1, map);
+
+ if (ostr.str () != ostr1.str ())
+ return 1;
+ }
+}