From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- tests/clash/clash.xsd | 25 + tests/clash/foo.xsd | 11 + tests/code/name-conflict/test.xsd | 40 + tests/code/name-escaping/test.xsd | 60 + tests/cxx/makefile | 19 + tests/cxx/parser/built-in/driver.cxx | 531 +++++++ tests/cxx/parser/built-in/makefile | 75 + tests/cxx/parser/built-in/output | 164 +++ tests/cxx/parser/built-in/test.xml | 199 +++ tests/cxx/parser/built-in/test.xsd | 63 + tests/cxx/parser/enumeration/driver.cxx | 83 ++ tests/cxx/parser/enumeration/gender.hxx | 15 + tests/cxx/parser/enumeration/makefile | 75 + tests/cxx/parser/enumeration/output | 3 + tests/cxx/parser/enumeration/test.map | 7 + tests/cxx/parser/enumeration/test.xml | 10 + tests/cxx/parser/enumeration/test.xsd | 35 + tests/cxx/parser/generated-impl/makefile | 81 ++ tests/cxx/parser/generated-impl/output | 122 ++ tests/cxx/parser/generated-impl/test.xml | 168 +++ tests/cxx/parser/generated-impl/test.xsd | 142 ++ tests/cxx/parser/list/driver.cxx | 107 ++ tests/cxx/parser/list/makefile | 74 + tests/cxx/parser/list/output | 26 + tests/cxx/parser/list/test.xml | 25 + tests/cxx/parser/list/test.xsd | 25 + tests/cxx/parser/makefile | 24 + tests/cxx/parser/name-clash/inheritance/driver.cxx | 64 + tests/cxx/parser/name-clash/inheritance/makefile | 75 + tests/cxx/parser/name-clash/inheritance/output | 2 + tests/cxx/parser/name-clash/inheritance/test.xml | 8 + tests/cxx/parser/name-clash/inheritance/test.xsd | 22 + tests/cxx/parser/polymorphism/makefile | 22 + tests/cxx/parser/polymorphism/same-type/driver.cxx | 64 + tests/cxx/parser/polymorphism/same-type/makefile | 75 + tests/cxx/parser/polymorphism/same-type/output | 4 + tests/cxx/parser/polymorphism/same-type/test.xml | 10 + tests/cxx/parser/polymorphism/same-type/test.xsd | 21 + tests/cxx/parser/recursive/driver.cxx | 141 ++ tests/cxx/parser/recursive/makefile | 75 + tests/cxx/parser/recursive/output | 22 + tests/cxx/parser/recursive/test.xml | 11 + tests/cxx/parser/recursive/test.xsd | 27 + tests/cxx/parser/test-template/driver.cxx | 68 + tests/cxx/parser/test-template/makefile | 74 + tests/cxx/parser/test-template/output | 1 + tests/cxx/parser/test-template/test.xml | 7 + tests/cxx/parser/test-template/test.xsd | 12 + tests/cxx/parser/union/driver.cxx | 62 + tests/cxx/parser/union/makefile | 74 + tests/cxx/parser/union/output | 2 + tests/cxx/parser/union/test.xml | 10 + tests/cxx/parser/union/test.xsd | 16 + tests/cxx/parser/validation/all/driver.cxx | 100 ++ tests/cxx/parser/validation/all/makefile | 85 ++ tests/cxx/parser/validation/all/test-000.std | 46 + tests/cxx/parser/validation/all/test-000.xml | 53 + tests/cxx/parser/validation/all/test-001.std | 6 + tests/cxx/parser/validation/all/test-001.xml | 11 + tests/cxx/parser/validation/all/test-002.std | 4 + tests/cxx/parser/validation/all/test-002.xml | 9 + tests/cxx/parser/validation/all/test-003.std | 6 + tests/cxx/parser/validation/all/test-003.xml | 12 + tests/cxx/parser/validation/all/test.xsd | 20 + tests/cxx/parser/validation/any/driver.cxx | 123 ++ tests/cxx/parser/validation/any/makefile | 85 ++ tests/cxx/parser/validation/any/test-000.std | 29 + tests/cxx/parser/validation/any/test-000.xml | 21 + tests/cxx/parser/validation/any/test.xsd | 20 + tests/cxx/parser/validation/attribute/driver.cxx | 199 +++ tests/cxx/parser/validation/attribute/makefile | 85 ++ tests/cxx/parser/validation/attribute/test-000.std | 24 + tests/cxx/parser/validation/attribute/test-000.xml | 10 + tests/cxx/parser/validation/attribute/test.xsd | 71 + .../parser/validation/built-in/any-type/driver.cxx | 156 ++ .../parser/validation/built-in/any-type/makefile | 85 ++ .../validation/built-in/any-type/test-000.std | 99 ++ .../validation/built-in/any-type/test-000.xml | 41 + .../parser/validation/built-in/any-type/test.xsd | 31 + .../parser/validation/built-in/binary/driver.cxx | 155 ++ .../cxx/parser/validation/built-in/binary/makefile | 60 + .../parser/validation/built-in/boolean/driver.cxx | 147 ++ .../parser/validation/built-in/boolean/makefile | 60 + .../cxx/parser/validation/built-in/byte/driver.cxx | 258 ++++ tests/cxx/parser/validation/built-in/byte/makefile | 60 + .../validation/built-in/date-time/driver.cxx | 1535 ++++++++++++++++++++ .../parser/validation/built-in/date-time/makefile | 60 + .../parser/validation/built-in/float/driver.cxx | 287 ++++ .../cxx/parser/validation/built-in/float/makefile | 60 + .../cxx/parser/validation/built-in/int/driver.cxx | 118 ++ tests/cxx/parser/validation/built-in/int/makefile | 60 + .../parser/validation/built-in/integer/driver.cxx | 305 ++++ .../parser/validation/built-in/integer/makefile | 60 + .../cxx/parser/validation/built-in/long/driver.cxx | 118 ++ tests/cxx/parser/validation/built-in/long/makefile | 60 + tests/cxx/parser/validation/built-in/makefile | 21 + .../parser/validation/built-in/qname/driver.cxx | 107 ++ .../cxx/parser/validation/built-in/qname/makefile | 60 + .../parser/validation/built-in/short/driver.cxx | 118 ++ .../cxx/parser/validation/built-in/short/makefile | 60 + .../parser/validation/built-in/string/driver.cxx | 514 +++++++ .../cxx/parser/validation/built-in/string/makefile | 60 + .../cxx/parser/validation/built-in/uri/driver.cxx | 55 + tests/cxx/parser/validation/built-in/uri/makefile | 60 + tests/cxx/parser/validation/choice/driver.cxx | 128 ++ tests/cxx/parser/validation/choice/makefile | 85 ++ tests/cxx/parser/validation/choice/test-000.std | 22 + tests/cxx/parser/validation/choice/test-000.xml | 30 + tests/cxx/parser/validation/choice/test-001.std | 4 + tests/cxx/parser/validation/choice/test-001.xml | 10 + tests/cxx/parser/validation/choice/test-002.std | 11 + tests/cxx/parser/validation/choice/test-002.xml | 17 + tests/cxx/parser/validation/choice/test-003.std | 5 + tests/cxx/parser/validation/choice/test-003.xml | 11 + tests/cxx/parser/validation/choice/test-004.std | 4 + tests/cxx/parser/validation/choice/test-004.xml | 11 + tests/cxx/parser/validation/choice/test.xsd | 24 + tests/cxx/parser/validation/makefile | 22 + tests/cxx/parser/validation/restriction/driver.cxx | 109 ++ tests/cxx/parser/validation/restriction/makefile | 85 ++ .../cxx/parser/validation/restriction/test-000.std | 0 .../cxx/parser/validation/restriction/test-000.xml | 31 + .../cxx/parser/validation/restriction/test-001.std | 1 + .../cxx/parser/validation/restriction/test-001.xml | 11 + .../cxx/parser/validation/restriction/test-002.std | 1 + .../cxx/parser/validation/restriction/test-002.xml | 12 + .../cxx/parser/validation/restriction/test-003.std | 1 + .../cxx/parser/validation/restriction/test-003.xml | 16 + .../cxx/parser/validation/restriction/test-004.std | 1 + .../cxx/parser/validation/restriction/test-004.xml | 10 + .../cxx/parser/validation/restriction/test-005.std | 1 + .../cxx/parser/validation/restriction/test-005.xml | 11 + tests/cxx/parser/validation/restriction/test.xsd | 82 ++ tests/cxx/parser/validation/sequence/driver.cxx | 141 ++ tests/cxx/parser/validation/sequence/makefile | 85 ++ tests/cxx/parser/validation/sequence/test-000.std | 56 + tests/cxx/parser/validation/sequence/test-000.xml | 46 + tests/cxx/parser/validation/sequence/test-001.std | 4 + tests/cxx/parser/validation/sequence/test-001.xml | 10 + tests/cxx/parser/validation/sequence/test-002.std | 20 + tests/cxx/parser/validation/sequence/test-002.xml | 27 + tests/cxx/parser/validation/sequence/test-003.std | 5 + tests/cxx/parser/validation/sequence/test-003.xml | 17 + tests/cxx/parser/validation/sequence/test-004.std | 4 + tests/cxx/parser/validation/sequence/test-004.xml | 14 + tests/cxx/parser/validation/sequence/test-005.std | 6 + tests/cxx/parser/validation/sequence/test-005.xml | 15 + tests/cxx/parser/validation/sequence/test-006.std | 13 + tests/cxx/parser/validation/sequence/test-006.xml | 17 + tests/cxx/parser/validation/sequence/test.xsd | 28 + tests/cxx/tree/binary/cdr/driver.cxx | 137 ++ tests/cxx/tree/binary/cdr/makefile | 86 ++ tests/cxx/tree/binary/cdr/test.xml | 91 ++ tests/cxx/tree/binary/cdr/test.xsd | 120 ++ tests/cxx/tree/binary/makefile | 20 + tests/cxx/tree/binary/polymorphic/driver.cxx | 151 ++ tests/cxx/tree/binary/polymorphic/makefile | 87 ++ tests/cxx/tree/binary/polymorphic/test.xml | 92 ++ tests/cxx/tree/binary/polymorphic/test.xsd | 125 ++ tests/cxx/tree/binary/xdr/driver.cxx | 181 +++ tests/cxx/tree/binary/xdr/makefile | 81 ++ tests/cxx/tree/binary/xdr/test.xml | 91 ++ tests/cxx/tree/binary/xdr/test.xsd | 120 ++ tests/cxx/tree/built-in/attributes.xml | 73 + tests/cxx/tree/built-in/driver.cxx | 94 ++ tests/cxx/tree/built-in/elements.xml | 84 ++ tests/cxx/tree/built-in/inherited.xml | 84 ++ tests/cxx/tree/built-in/makefile | 93 ++ tests/cxx/tree/built-in/types.xsd | 460 ++++++ tests/cxx/tree/chameleon/driver.cxx | 37 + tests/cxx/tree/chameleon/includee.xsd | 13 + tests/cxx/tree/chameleon/includer.xsd | 12 + tests/cxx/tree/chameleon/makefile | 82 ++ tests/cxx/tree/chameleon/output | 3 + tests/cxx/tree/chameleon/test.xml | 8 + tests/cxx/tree/comparison/driver.cxx | 40 + tests/cxx/tree/comparison/makefile | 81 ++ tests/cxx/tree/comparison/test.xml | 19 + tests/cxx/tree/comparison/test.xsd | 30 + tests/cxx/tree/compilation/driver.cxx | 119 ++ tests/cxx/tree/compilation/makefile | 81 ++ tests/cxx/tree/compilation/test.xsd | 12 + tests/cxx/tree/complex/ctor/driver.cxx | 112 ++ tests/cxx/tree/complex/ctor/makefile | 83 ++ tests/cxx/tree/complex/ctor/test.xsd | 182 +++ tests/cxx/tree/complex/makefile | 20 + tests/cxx/tree/containment/driver.cxx | 77 + tests/cxx/tree/containment/makefile | 81 ++ tests/cxx/tree/containment/test.xsd | 27 + tests/cxx/tree/default/driver.cxx | 48 + tests/cxx/tree/default/makefile | 83 ++ tests/cxx/tree/default/output | 26 + tests/cxx/tree/default/test.xml | 11 + tests/cxx/tree/default/test.xsd | 39 + tests/cxx/tree/encoding/char/lcp/driver.cxx | 42 + tests/cxx/tree/encoding/char/lcp/makefile | 81 ++ tests/cxx/tree/encoding/char/lcp/test.std | 6 + tests/cxx/tree/encoding/char/lcp/test.xml | 7 + tests/cxx/tree/encoding/char/lcp/test.xsd | 12 + tests/cxx/tree/encoding/char/makefile | 22 + tests/cxx/tree/encoding/char/utf-8/driver.cxx | 67 + tests/cxx/tree/encoding/char/utf-8/makefile | 82 ++ tests/cxx/tree/encoding/char/utf-8/test.std | Bin 0 -> 796 bytes tests/cxx/tree/encoding/char/utf-8/test.xml | 15 + tests/cxx/tree/encoding/char/utf-8/test.xsd | 33 + tests/cxx/tree/encoding/makefile | 22 + tests/cxx/tree/encoding/wchar/driver.cxx | 57 + tests/cxx/tree/encoding/wchar/makefile | 82 ++ tests/cxx/tree/encoding/wchar/test.std | Bin 0 -> 768 bytes tests/cxx/tree/encoding/wchar/test.xml | 14 + tests/cxx/tree/encoding/wchar/test.xsd | 33 + tests/cxx/tree/enumeration/ctor/driver.cxx | 32 + tests/cxx/tree/enumeration/ctor/makefile | 82 ++ tests/cxx/tree/enumeration/ctor/test.xsd | 41 + tests/cxx/tree/enumeration/inheritance/driver.cxx | 49 + tests/cxx/tree/enumeration/inheritance/makefile | 81 ++ tests/cxx/tree/enumeration/inheritance/output | 1 + tests/cxx/tree/enumeration/inheritance/test.xml | 3 + tests/cxx/tree/enumeration/inheritance/test.xsd | 22 + tests/cxx/tree/enumeration/makefile | 20 + tests/cxx/tree/float/driver.cxx | 55 + tests/cxx/tree/float/makefile | 81 ++ tests/cxx/tree/float/test.std | 68 + tests/cxx/tree/float/test.xml | 35 + tests/cxx/tree/float/test.xsd | 74 + tests/cxx/tree/list/ctor/driver.cxx | 52 + tests/cxx/tree/list/ctor/makefile | 82 ++ tests/cxx/tree/list/ctor/test.xsd | 18 + tests/cxx/tree/list/makefile | 20 + tests/cxx/tree/makefile | 43 + tests/cxx/tree/name-clash/inheritance/driver.cxx | 37 + tests/cxx/tree/name-clash/inheritance/makefile | 81 ++ tests/cxx/tree/name-clash/inheritance/output | 3 + tests/cxx/tree/name-clash/inheritance/test.xml | 8 + tests/cxx/tree/name-clash/inheritance/test.xsd | 53 + tests/cxx/tree/name-clash/makefile | 20 + tests/cxx/tree/naming/camel/driver.cxx | 145 ++ tests/cxx/tree/naming/camel/makefile | 87 ++ tests/cxx/tree/naming/camel/test.xsd | 31 + tests/cxx/tree/naming/java/driver.cxx | 145 ++ tests/cxx/tree/naming/java/makefile | 87 ++ tests/cxx/tree/naming/java/test.xsd | 31 + tests/cxx/tree/naming/knr/driver.cxx | 145 ++ tests/cxx/tree/naming/knr/makefile | 87 ++ tests/cxx/tree/naming/knr/test.xsd | 31 + tests/cxx/tree/naming/makefile | 20 + tests/cxx/tree/polymorphism/comparison/driver.cxx | 75 + tests/cxx/tree/polymorphism/comparison/makefile | 82 ++ tests/cxx/tree/polymorphism/comparison/test.xml | 7 + tests/cxx/tree/polymorphism/comparison/test.xsd | 39 + tests/cxx/tree/polymorphism/makefile | 20 + tests/cxx/tree/polymorphism/ostream/driver.cxx | 36 + tests/cxx/tree/polymorphism/ostream/makefile | 83 ++ tests/cxx/tree/polymorphism/ostream/output | 13 + tests/cxx/tree/polymorphism/ostream/test.xml | 9 + tests/cxx/tree/polymorphism/ostream/test.xsd | 39 + tests/cxx/tree/polymorphism/same-type/driver.cxx | 37 + tests/cxx/tree/polymorphism/same-type/makefile | 82 ++ tests/cxx/tree/polymorphism/same-type/output | 9 + tests/cxx/tree/polymorphism/same-type/test.xml | 10 + tests/cxx/tree/polymorphism/same-type/test.xsd | 21 + tests/cxx/tree/prefix/bar.xsd | 34 + tests/cxx/tree/prefix/driver.cxx | 36 + tests/cxx/tree/prefix/foo.xsd | 16 + tests/cxx/tree/prefix/makefile | 76 + tests/cxx/tree/prefix/output | 22 + tests/cxx/tree/prefix/test.xml | 19 + tests/cxx/tree/prefix/test.xsd | 40 + tests/cxx/tree/test-template/driver.cxx | 37 + tests/cxx/tree/test-template/makefile | 81 ++ tests/cxx/tree/test-template/output | 2 + tests/cxx/tree/test-template/test.xml | 7 + tests/cxx/tree/test-template/test.xsd | 12 + tests/cxx/tree/types-only/driver.cxx | 33 + tests/cxx/tree/types-only/makefile | 81 ++ tests/cxx/tree/types-only/test.xsd | 52 + tests/cxx/tree/union/ctor/driver.cxx | 32 + tests/cxx/tree/union/ctor/makefile | 82 ++ tests/cxx/tree/union/ctor/test.xsd | 14 + tests/cxx/tree/union/makefile | 20 + tests/cxx/tree/wildcard/driver.cxx | 202 +++ tests/cxx/tree/wildcard/makefile | 83 ++ tests/cxx/tree/wildcard/output | 24 + tests/cxx/tree/wildcard/test.xml | 19 + tests/cxx/tree/wildcard/test.xsd | 18 + tests/failed/test-00.xsd | 12 + tests/makefile | 18 + tests/morphing/anonymous/attribute-group/test.xsd | 31 + .../anonymous/cyclic-inclusion/includee.xsd | 18 + .../anonymous/cyclic-inclusion/includer.xsd | 18 + tests/morphing/anonymous/group/test.xsd | 29 + tests/morphing/anonymous/test-000.xsd | 20 + tests/morphing/anonymous/unstable/includee-1.xsd | 12 + tests/morphing/anonymous/unstable/includee-2.xsd | 14 + tests/morphing/anonymous/unstable/includer.xsd | 18 + tests/processing/inheritance/test-000.xsd | 22 + tests/processing/inheritance/test-001.xsd | 26 + tests/schema/anonymous/test.xsd | 143 ++ tests/schema/any-attribute/test.xsd | 22 + tests/schema/any-type/test.xsd | 22 + tests/schema/any/fail.xsd | 19 + tests/schema/any/test.xsd | 19 + tests/schema/attribute-group/global.xsd | 50 + tests/schema/attribute/global.xsd | 21 + tests/schema/attribute/local.xsd | 37 + tests/schema/attribute/ref.xsd | 42 + tests/schema/cardinality/test.xsd | 46 + tests/schema/chameleon/includer.xsd | 17 + tests/schema/chameleon/schemas/includee.xsd | 12 + tests/schema/enumeration/test.xsd | 89 ++ tests/schema/forward/test.xsd | 32 + tests/schema/group/global.xsd | 39 + tests/schema/group/test.xsd | 148 ++ tests/schema/import/importer.xsd | 20 + tests/schema/import/schemas/importee.xsd | 15 + tests/schema/include/includer.xsd | 17 + tests/schema/include/schemas/includee.xsd | 14 + tests/schema/inheritance/cycle.xsd | 34 + .../inheritance/sourced-forward/includee.xsd | 10 + .../inheritance/sourced-forward/includer.xsd | 14 + tests/schema/list/anonymous/test.xsd | 16 + tests/schema/list/any-simple-type/test.xsd | 12 + tests/schema/list/driver.cxx | 13 + tests/schema/list/test.xsd | 72 + tests/schema/no-namespace/test.xsd | 15 + tests/schema/recursive/test.xsd | 43 + tests/schema/ref-type/idref.xsd | 42 + tests/schema/ref-type/idrefs.xsd | 43 + tests/schema/ref-type/invalid-0.xsd | 17 + tests/schema/ref-type/invalid-1.xsd | 11 + tests/schema/restriction/test.xsd | 67 + tests/schema/union/test.xsd | 65 + 332 files changed, 19512 insertions(+) create mode 100644 tests/clash/clash.xsd create mode 100644 tests/clash/foo.xsd create mode 100644 tests/code/name-conflict/test.xsd create mode 100644 tests/code/name-escaping/test.xsd create mode 100644 tests/cxx/makefile create mode 100644 tests/cxx/parser/built-in/driver.cxx create mode 100644 tests/cxx/parser/built-in/makefile create mode 100644 tests/cxx/parser/built-in/output create mode 100644 tests/cxx/parser/built-in/test.xml create mode 100644 tests/cxx/parser/built-in/test.xsd create mode 100644 tests/cxx/parser/enumeration/driver.cxx create mode 100644 tests/cxx/parser/enumeration/gender.hxx create mode 100644 tests/cxx/parser/enumeration/makefile create mode 100644 tests/cxx/parser/enumeration/output create mode 100644 tests/cxx/parser/enumeration/test.map create mode 100644 tests/cxx/parser/enumeration/test.xml create mode 100644 tests/cxx/parser/enumeration/test.xsd create mode 100644 tests/cxx/parser/generated-impl/makefile create mode 100644 tests/cxx/parser/generated-impl/output create mode 100644 tests/cxx/parser/generated-impl/test.xml create mode 100644 tests/cxx/parser/generated-impl/test.xsd create mode 100644 tests/cxx/parser/list/driver.cxx create mode 100644 tests/cxx/parser/list/makefile create mode 100644 tests/cxx/parser/list/output create mode 100644 tests/cxx/parser/list/test.xml create mode 100644 tests/cxx/parser/list/test.xsd create mode 100644 tests/cxx/parser/makefile create mode 100644 tests/cxx/parser/name-clash/inheritance/driver.cxx create mode 100644 tests/cxx/parser/name-clash/inheritance/makefile create mode 100644 tests/cxx/parser/name-clash/inheritance/output create mode 100644 tests/cxx/parser/name-clash/inheritance/test.xml create mode 100644 tests/cxx/parser/name-clash/inheritance/test.xsd create mode 100644 tests/cxx/parser/polymorphism/makefile create mode 100644 tests/cxx/parser/polymorphism/same-type/driver.cxx create mode 100644 tests/cxx/parser/polymorphism/same-type/makefile create mode 100644 tests/cxx/parser/polymorphism/same-type/output create mode 100644 tests/cxx/parser/polymorphism/same-type/test.xml create mode 100644 tests/cxx/parser/polymorphism/same-type/test.xsd create mode 100644 tests/cxx/parser/recursive/driver.cxx create mode 100644 tests/cxx/parser/recursive/makefile create mode 100644 tests/cxx/parser/recursive/output create mode 100644 tests/cxx/parser/recursive/test.xml create mode 100644 tests/cxx/parser/recursive/test.xsd create mode 100644 tests/cxx/parser/test-template/driver.cxx create mode 100644 tests/cxx/parser/test-template/makefile create mode 100644 tests/cxx/parser/test-template/output create mode 100644 tests/cxx/parser/test-template/test.xml create mode 100644 tests/cxx/parser/test-template/test.xsd create mode 100644 tests/cxx/parser/union/driver.cxx create mode 100644 tests/cxx/parser/union/makefile create mode 100644 tests/cxx/parser/union/output create mode 100644 tests/cxx/parser/union/test.xml create mode 100644 tests/cxx/parser/union/test.xsd create mode 100644 tests/cxx/parser/validation/all/driver.cxx create mode 100644 tests/cxx/parser/validation/all/makefile create mode 100644 tests/cxx/parser/validation/all/test-000.std create mode 100644 tests/cxx/parser/validation/all/test-000.xml create mode 100644 tests/cxx/parser/validation/all/test-001.std create mode 100644 tests/cxx/parser/validation/all/test-001.xml create mode 100644 tests/cxx/parser/validation/all/test-002.std create mode 100644 tests/cxx/parser/validation/all/test-002.xml create mode 100644 tests/cxx/parser/validation/all/test-003.std create mode 100644 tests/cxx/parser/validation/all/test-003.xml create mode 100644 tests/cxx/parser/validation/all/test.xsd create mode 100644 tests/cxx/parser/validation/any/driver.cxx create mode 100644 tests/cxx/parser/validation/any/makefile create mode 100644 tests/cxx/parser/validation/any/test-000.std create mode 100644 tests/cxx/parser/validation/any/test-000.xml create mode 100644 tests/cxx/parser/validation/any/test.xsd create mode 100644 tests/cxx/parser/validation/attribute/driver.cxx create mode 100644 tests/cxx/parser/validation/attribute/makefile create mode 100644 tests/cxx/parser/validation/attribute/test-000.std create mode 100644 tests/cxx/parser/validation/attribute/test-000.xml create mode 100644 tests/cxx/parser/validation/attribute/test.xsd create mode 100644 tests/cxx/parser/validation/built-in/any-type/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/any-type/makefile create mode 100644 tests/cxx/parser/validation/built-in/any-type/test-000.std create mode 100644 tests/cxx/parser/validation/built-in/any-type/test-000.xml create mode 100644 tests/cxx/parser/validation/built-in/any-type/test.xsd create mode 100644 tests/cxx/parser/validation/built-in/binary/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/binary/makefile create mode 100644 tests/cxx/parser/validation/built-in/boolean/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/boolean/makefile create mode 100644 tests/cxx/parser/validation/built-in/byte/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/byte/makefile create mode 100644 tests/cxx/parser/validation/built-in/date-time/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/date-time/makefile create mode 100644 tests/cxx/parser/validation/built-in/float/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/float/makefile create mode 100644 tests/cxx/parser/validation/built-in/int/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/int/makefile create mode 100644 tests/cxx/parser/validation/built-in/integer/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/integer/makefile create mode 100644 tests/cxx/parser/validation/built-in/long/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/long/makefile create mode 100644 tests/cxx/parser/validation/built-in/makefile create mode 100644 tests/cxx/parser/validation/built-in/qname/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/qname/makefile create mode 100644 tests/cxx/parser/validation/built-in/short/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/short/makefile create mode 100644 tests/cxx/parser/validation/built-in/string/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/string/makefile create mode 100644 tests/cxx/parser/validation/built-in/uri/driver.cxx create mode 100644 tests/cxx/parser/validation/built-in/uri/makefile create mode 100644 tests/cxx/parser/validation/choice/driver.cxx create mode 100644 tests/cxx/parser/validation/choice/makefile create mode 100644 tests/cxx/parser/validation/choice/test-000.std create mode 100644 tests/cxx/parser/validation/choice/test-000.xml create mode 100644 tests/cxx/parser/validation/choice/test-001.std create mode 100644 tests/cxx/parser/validation/choice/test-001.xml create mode 100644 tests/cxx/parser/validation/choice/test-002.std create mode 100644 tests/cxx/parser/validation/choice/test-002.xml create mode 100644 tests/cxx/parser/validation/choice/test-003.std create mode 100644 tests/cxx/parser/validation/choice/test-003.xml create mode 100644 tests/cxx/parser/validation/choice/test-004.std create mode 100644 tests/cxx/parser/validation/choice/test-004.xml create mode 100644 tests/cxx/parser/validation/choice/test.xsd create mode 100644 tests/cxx/parser/validation/makefile create mode 100644 tests/cxx/parser/validation/restriction/driver.cxx create mode 100644 tests/cxx/parser/validation/restriction/makefile create mode 100644 tests/cxx/parser/validation/restriction/test-000.std create mode 100644 tests/cxx/parser/validation/restriction/test-000.xml create mode 100644 tests/cxx/parser/validation/restriction/test-001.std create mode 100644 tests/cxx/parser/validation/restriction/test-001.xml create mode 100644 tests/cxx/parser/validation/restriction/test-002.std create mode 100644 tests/cxx/parser/validation/restriction/test-002.xml create mode 100644 tests/cxx/parser/validation/restriction/test-003.std create mode 100644 tests/cxx/parser/validation/restriction/test-003.xml create mode 100644 tests/cxx/parser/validation/restriction/test-004.std create mode 100644 tests/cxx/parser/validation/restriction/test-004.xml create mode 100644 tests/cxx/parser/validation/restriction/test-005.std create mode 100644 tests/cxx/parser/validation/restriction/test-005.xml create mode 100644 tests/cxx/parser/validation/restriction/test.xsd create mode 100644 tests/cxx/parser/validation/sequence/driver.cxx create mode 100644 tests/cxx/parser/validation/sequence/makefile create mode 100644 tests/cxx/parser/validation/sequence/test-000.std create mode 100644 tests/cxx/parser/validation/sequence/test-000.xml create mode 100644 tests/cxx/parser/validation/sequence/test-001.std create mode 100644 tests/cxx/parser/validation/sequence/test-001.xml create mode 100644 tests/cxx/parser/validation/sequence/test-002.std create mode 100644 tests/cxx/parser/validation/sequence/test-002.xml create mode 100644 tests/cxx/parser/validation/sequence/test-003.std create mode 100644 tests/cxx/parser/validation/sequence/test-003.xml create mode 100644 tests/cxx/parser/validation/sequence/test-004.std create mode 100644 tests/cxx/parser/validation/sequence/test-004.xml create mode 100644 tests/cxx/parser/validation/sequence/test-005.std create mode 100644 tests/cxx/parser/validation/sequence/test-005.xml create mode 100644 tests/cxx/parser/validation/sequence/test-006.std create mode 100644 tests/cxx/parser/validation/sequence/test-006.xml create mode 100644 tests/cxx/parser/validation/sequence/test.xsd create mode 100644 tests/cxx/tree/binary/cdr/driver.cxx create mode 100644 tests/cxx/tree/binary/cdr/makefile create mode 100644 tests/cxx/tree/binary/cdr/test.xml create mode 100644 tests/cxx/tree/binary/cdr/test.xsd create mode 100644 tests/cxx/tree/binary/makefile create mode 100644 tests/cxx/tree/binary/polymorphic/driver.cxx create mode 100644 tests/cxx/tree/binary/polymorphic/makefile create mode 100644 tests/cxx/tree/binary/polymorphic/test.xml create mode 100644 tests/cxx/tree/binary/polymorphic/test.xsd create mode 100644 tests/cxx/tree/binary/xdr/driver.cxx create mode 100644 tests/cxx/tree/binary/xdr/makefile create mode 100644 tests/cxx/tree/binary/xdr/test.xml create mode 100644 tests/cxx/tree/binary/xdr/test.xsd create mode 100644 tests/cxx/tree/built-in/attributes.xml create mode 100644 tests/cxx/tree/built-in/driver.cxx create mode 100644 tests/cxx/tree/built-in/elements.xml create mode 100644 tests/cxx/tree/built-in/inherited.xml create mode 100644 tests/cxx/tree/built-in/makefile create mode 100644 tests/cxx/tree/built-in/types.xsd create mode 100644 tests/cxx/tree/chameleon/driver.cxx create mode 100644 tests/cxx/tree/chameleon/includee.xsd create mode 100644 tests/cxx/tree/chameleon/includer.xsd create mode 100644 tests/cxx/tree/chameleon/makefile create mode 100644 tests/cxx/tree/chameleon/output create mode 100644 tests/cxx/tree/chameleon/test.xml create mode 100644 tests/cxx/tree/comparison/driver.cxx create mode 100644 tests/cxx/tree/comparison/makefile create mode 100644 tests/cxx/tree/comparison/test.xml create mode 100644 tests/cxx/tree/comparison/test.xsd create mode 100644 tests/cxx/tree/compilation/driver.cxx create mode 100644 tests/cxx/tree/compilation/makefile create mode 100644 tests/cxx/tree/compilation/test.xsd create mode 100644 tests/cxx/tree/complex/ctor/driver.cxx create mode 100644 tests/cxx/tree/complex/ctor/makefile create mode 100644 tests/cxx/tree/complex/ctor/test.xsd create mode 100644 tests/cxx/tree/complex/makefile create mode 100644 tests/cxx/tree/containment/driver.cxx create mode 100644 tests/cxx/tree/containment/makefile create mode 100644 tests/cxx/tree/containment/test.xsd create mode 100644 tests/cxx/tree/default/driver.cxx create mode 100644 tests/cxx/tree/default/makefile create mode 100644 tests/cxx/tree/default/output create mode 100644 tests/cxx/tree/default/test.xml create mode 100644 tests/cxx/tree/default/test.xsd create mode 100644 tests/cxx/tree/encoding/char/lcp/driver.cxx create mode 100644 tests/cxx/tree/encoding/char/lcp/makefile create mode 100644 tests/cxx/tree/encoding/char/lcp/test.std create mode 100644 tests/cxx/tree/encoding/char/lcp/test.xml create mode 100644 tests/cxx/tree/encoding/char/lcp/test.xsd create mode 100644 tests/cxx/tree/encoding/char/makefile create mode 100644 tests/cxx/tree/encoding/char/utf-8/driver.cxx create mode 100644 tests/cxx/tree/encoding/char/utf-8/makefile create mode 100644 tests/cxx/tree/encoding/char/utf-8/test.std create mode 100644 tests/cxx/tree/encoding/char/utf-8/test.xml create mode 100644 tests/cxx/tree/encoding/char/utf-8/test.xsd create mode 100644 tests/cxx/tree/encoding/makefile create mode 100644 tests/cxx/tree/encoding/wchar/driver.cxx create mode 100644 tests/cxx/tree/encoding/wchar/makefile create mode 100644 tests/cxx/tree/encoding/wchar/test.std create mode 100644 tests/cxx/tree/encoding/wchar/test.xml create mode 100644 tests/cxx/tree/encoding/wchar/test.xsd create mode 100644 tests/cxx/tree/enumeration/ctor/driver.cxx create mode 100644 tests/cxx/tree/enumeration/ctor/makefile create mode 100644 tests/cxx/tree/enumeration/ctor/test.xsd create mode 100644 tests/cxx/tree/enumeration/inheritance/driver.cxx create mode 100644 tests/cxx/tree/enumeration/inheritance/makefile create mode 100644 tests/cxx/tree/enumeration/inheritance/output create mode 100644 tests/cxx/tree/enumeration/inheritance/test.xml create mode 100644 tests/cxx/tree/enumeration/inheritance/test.xsd create mode 100644 tests/cxx/tree/enumeration/makefile create mode 100644 tests/cxx/tree/float/driver.cxx create mode 100644 tests/cxx/tree/float/makefile create mode 100644 tests/cxx/tree/float/test.std create mode 100644 tests/cxx/tree/float/test.xml create mode 100644 tests/cxx/tree/float/test.xsd create mode 100644 tests/cxx/tree/list/ctor/driver.cxx create mode 100644 tests/cxx/tree/list/ctor/makefile create mode 100644 tests/cxx/tree/list/ctor/test.xsd create mode 100644 tests/cxx/tree/list/makefile create mode 100644 tests/cxx/tree/makefile create mode 100644 tests/cxx/tree/name-clash/inheritance/driver.cxx create mode 100644 tests/cxx/tree/name-clash/inheritance/makefile create mode 100644 tests/cxx/tree/name-clash/inheritance/output create mode 100644 tests/cxx/tree/name-clash/inheritance/test.xml create mode 100644 tests/cxx/tree/name-clash/inheritance/test.xsd create mode 100644 tests/cxx/tree/name-clash/makefile create mode 100644 tests/cxx/tree/naming/camel/driver.cxx create mode 100644 tests/cxx/tree/naming/camel/makefile create mode 100644 tests/cxx/tree/naming/camel/test.xsd create mode 100644 tests/cxx/tree/naming/java/driver.cxx create mode 100644 tests/cxx/tree/naming/java/makefile create mode 100644 tests/cxx/tree/naming/java/test.xsd create mode 100644 tests/cxx/tree/naming/knr/driver.cxx create mode 100644 tests/cxx/tree/naming/knr/makefile create mode 100644 tests/cxx/tree/naming/knr/test.xsd create mode 100644 tests/cxx/tree/naming/makefile create mode 100644 tests/cxx/tree/polymorphism/comparison/driver.cxx create mode 100644 tests/cxx/tree/polymorphism/comparison/makefile create mode 100644 tests/cxx/tree/polymorphism/comparison/test.xml create mode 100644 tests/cxx/tree/polymorphism/comparison/test.xsd create mode 100644 tests/cxx/tree/polymorphism/makefile create mode 100644 tests/cxx/tree/polymorphism/ostream/driver.cxx create mode 100644 tests/cxx/tree/polymorphism/ostream/makefile create mode 100644 tests/cxx/tree/polymorphism/ostream/output create mode 100644 tests/cxx/tree/polymorphism/ostream/test.xml create mode 100644 tests/cxx/tree/polymorphism/ostream/test.xsd create mode 100644 tests/cxx/tree/polymorphism/same-type/driver.cxx create mode 100644 tests/cxx/tree/polymorphism/same-type/makefile create mode 100644 tests/cxx/tree/polymorphism/same-type/output create mode 100644 tests/cxx/tree/polymorphism/same-type/test.xml create mode 100644 tests/cxx/tree/polymorphism/same-type/test.xsd create mode 100644 tests/cxx/tree/prefix/bar.xsd create mode 100644 tests/cxx/tree/prefix/driver.cxx create mode 100644 tests/cxx/tree/prefix/foo.xsd create mode 100644 tests/cxx/tree/prefix/makefile create mode 100644 tests/cxx/tree/prefix/output create mode 100644 tests/cxx/tree/prefix/test.xml create mode 100644 tests/cxx/tree/prefix/test.xsd create mode 100644 tests/cxx/tree/test-template/driver.cxx create mode 100644 tests/cxx/tree/test-template/makefile create mode 100644 tests/cxx/tree/test-template/output create mode 100644 tests/cxx/tree/test-template/test.xml create mode 100644 tests/cxx/tree/test-template/test.xsd create mode 100644 tests/cxx/tree/types-only/driver.cxx create mode 100644 tests/cxx/tree/types-only/makefile create mode 100644 tests/cxx/tree/types-only/test.xsd create mode 100644 tests/cxx/tree/union/ctor/driver.cxx create mode 100644 tests/cxx/tree/union/ctor/makefile create mode 100644 tests/cxx/tree/union/ctor/test.xsd create mode 100644 tests/cxx/tree/union/makefile create mode 100644 tests/cxx/tree/wildcard/driver.cxx create mode 100644 tests/cxx/tree/wildcard/makefile create mode 100644 tests/cxx/tree/wildcard/output create mode 100644 tests/cxx/tree/wildcard/test.xml create mode 100644 tests/cxx/tree/wildcard/test.xsd create mode 100644 tests/failed/test-00.xsd create mode 100644 tests/makefile create mode 100644 tests/morphing/anonymous/attribute-group/test.xsd create mode 100644 tests/morphing/anonymous/cyclic-inclusion/includee.xsd create mode 100644 tests/morphing/anonymous/cyclic-inclusion/includer.xsd create mode 100644 tests/morphing/anonymous/group/test.xsd create mode 100644 tests/morphing/anonymous/test-000.xsd create mode 100644 tests/morphing/anonymous/unstable/includee-1.xsd create mode 100644 tests/morphing/anonymous/unstable/includee-2.xsd create mode 100644 tests/morphing/anonymous/unstable/includer.xsd create mode 100644 tests/processing/inheritance/test-000.xsd create mode 100644 tests/processing/inheritance/test-001.xsd create mode 100644 tests/schema/anonymous/test.xsd create mode 100644 tests/schema/any-attribute/test.xsd create mode 100644 tests/schema/any-type/test.xsd create mode 100644 tests/schema/any/fail.xsd create mode 100644 tests/schema/any/test.xsd create mode 100644 tests/schema/attribute-group/global.xsd create mode 100644 tests/schema/attribute/global.xsd create mode 100644 tests/schema/attribute/local.xsd create mode 100644 tests/schema/attribute/ref.xsd create mode 100644 tests/schema/cardinality/test.xsd create mode 100644 tests/schema/chameleon/includer.xsd create mode 100644 tests/schema/chameleon/schemas/includee.xsd create mode 100644 tests/schema/enumeration/test.xsd create mode 100644 tests/schema/forward/test.xsd create mode 100644 tests/schema/group/global.xsd create mode 100644 tests/schema/group/test.xsd create mode 100644 tests/schema/import/importer.xsd create mode 100644 tests/schema/import/schemas/importee.xsd create mode 100644 tests/schema/include/includer.xsd create mode 100644 tests/schema/include/schemas/includee.xsd create mode 100644 tests/schema/inheritance/cycle.xsd create mode 100644 tests/schema/inheritance/sourced-forward/includee.xsd create mode 100644 tests/schema/inheritance/sourced-forward/includer.xsd create mode 100644 tests/schema/list/anonymous/test.xsd create mode 100644 tests/schema/list/any-simple-type/test.xsd create mode 100644 tests/schema/list/driver.cxx create mode 100644 tests/schema/list/test.xsd create mode 100644 tests/schema/no-namespace/test.xsd create mode 100644 tests/schema/recursive/test.xsd create mode 100644 tests/schema/ref-type/idref.xsd create mode 100644 tests/schema/ref-type/idrefs.xsd create mode 100644 tests/schema/ref-type/invalid-0.xsd create mode 100644 tests/schema/ref-type/invalid-1.xsd create mode 100644 tests/schema/restriction/test.xsd create mode 100644 tests/schema/union/test.xsd (limited to 'tests') diff --git a/tests/clash/clash.xsd b/tests/clash/clash.xsd new file mode 100644 index 0000000..8458908 --- /dev/null +++ b/tests/clash/clash.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/clash/foo.xsd b/tests/clash/foo.xsd new file mode 100644 index 0000000..8a06ba8 --- /dev/null +++ b/tests/clash/foo.xsd @@ -0,0 +1,11 @@ + + + + + + + diff --git a/tests/code/name-conflict/test.xsd b/tests/code/name-conflict/test.xsd new file mode 100644 index 0000000..a017cc8 --- /dev/null +++ b/tests/code/name-conflict/test.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/code/name-escaping/test.xsd b/tests/code/name-escaping/test.xsd new file mode 100644 index 0000000..08c7530 --- /dev/null +++ b/tests/code/name-escaping/test.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/makefile b/tests/cxx/makefile new file mode 100644 index 0000000..8d4cbd5 --- /dev/null +++ b/tests/cxx/makefile @@ -0,0 +1,19 @@ +# file : tests/cxx/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(clean) + +$(default): $(out_base)/parser/ $(out_base)/tree/ +$(test): $(out_base)/parser/.test $(out_base)/tree/.test +$(clean): $(out_base)/parser/.clean $(out_base)/tree/.clean + +$(call import,$(src_base)/parser/makefile) +$(call import,$(src_base)/tree/makefile) diff --git a/tests/cxx/parser/built-in/driver.cxx b/tests/cxx/parser/built-in/driver.cxx new file mode 100644 index 0000000..5c9c6e8 --- /dev/null +++ b/tests/cxx/parser/built-in/driver.cxx @@ -0,0 +1,531 @@ +// file : tests/cxx/parser/built-in/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in type parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_type_pimpl: xml_schema::any_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_simple_type () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ + virtual void + boolean (bool v) + { + cout << v << endl; + } + + virtual void + byte (signed char v) + { + cout << short (v) << endl; + } + + virtual void + unsigned_byte (unsigned char v) + { + cout << (unsigned short) (v) << endl; + } + + virtual void + short_ (short v) + { + cout << v << endl; + } + + virtual void + unsigned_short (unsigned short v) + { + cout << v << endl; + } + + virtual void + int_ (int v) + { + cout << v << endl; + } + + virtual void + unsigned_int (unsigned int v) + { + cout << v << endl; + } + + virtual void + long_ (long long v) + { + cout << v << endl; + } + + virtual void + unsigned_long (unsigned long long v) + { + cout << v << endl; + } + + virtual void + integer (long long v) + { + cout << v << endl; + } + + virtual void + negative_integer (long long v) + { + cout << v << endl; + } + + + virtual void + non_positive_integer (long long v) + { + cout << v << endl; + } + + + virtual void + positive_integer (unsigned long long v) + { + cout << v << endl; + } + + virtual void + non_negative_integer (unsigned long long v) + { + cout << v << endl; + } + + virtual void + float_ (float v) + { + cout << v << endl; + } + + virtual void + double_ (double v) + { + cout << v << endl; + } + + virtual void + decimal (double v) + { + cout << v << endl; + } + + virtual void + string (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + normalized_string (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + token (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + name (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + nmtoken (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + nmtokens (xml_schema::string_sequence const& s) + { + cout << "'"; + + for (xml_schema::string_sequence::const_iterator i (s.begin ()); + i != s.end (); ++i) + cout << *i << " "; + + cout << "'" << endl; + } + + virtual void + ncname (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + id (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + idref (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + idrefs (xml_schema::string_sequence const& s) + { + cout << "'"; + + for (xml_schema::string_sequence::const_iterator i (s.begin ()); + i != s.end (); ++i) + cout << *i << " "; + + cout << "'" << endl; + } + + virtual void + language (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + uri (std::string const& v) + { + cout << "'" << v << "'" << endl; + } + + virtual void + qname (xml_schema::qname const& v) + { + cout << "'" << v.prefix () << ":" << v.name () << "'" << endl; + } + + virtual void + base64_binary (std::auto_ptr v) + { + std::string tmp (v->data (), v->size ()); + cout << "'" << tmp << "'" << endl; + } + + virtual void + hex_binary (std::auto_ptr v) + { + std::string tmp (v->data (), v->size ()); + cout << "'" << tmp << "'" << endl; + } + + virtual void + gday (xml_schema::gday const& v) + { + cout << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gmonth (xml_schema::gmonth const& v) + { + cout << v.month (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gyear (xml_schema::gyear const& v) + { + cout << v.year (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gmonth_day (xml_schema::gmonth_day const& v) + { + cout << v.month () << '-' << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + gyear_month (xml_schema::gyear_month const& v) + { + cout << v.year () << '-' << v.month (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + date (xml_schema::date const& v) + { + cout << v.year () << '-' << v.month () << '-' << v.day (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + time (xml_schema::time const& v) + { + cout << v.hours () << ':' << v.minutes () << ':' << v.seconds (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + date_time (xml_schema::date_time const& v) + { + cout << v.year () << '-' << v.month () << '-' << v.day () << 'T' + << v.hours () << ':' << v.minutes () << ':' << v.seconds (); + + if (v.zone_present ()) + cout << (v.zone_hours () < 0 ? "" : "+") << v.zone_hours () + << ':' << v.zone_minutes (); + + cout << endl; + } + + virtual void + duration (xml_schema::duration const& v) + { + cout << (v.negative () ? "-" : "") << 'P' + << v.years () << 'Y' + << v.months () << 'M' + << v.days () << 'D' + << 'T' + << v.hours () << 'H' + << v.minutes () << 'M' + << v.seconds () << 'S' + << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + any_type_pimpl any_type_p; + any_simple_type_pimpl any_simple_type_p; + + xml_schema::boolean_pimpl boolean_p; + + xml_schema::byte_pimpl byte_p; + xml_schema::unsigned_byte_pimpl unsigned_byte_p; + xml_schema::short_pimpl short_p; + xml_schema::unsigned_short_pimpl unsigned_short_p; + xml_schema::int_pimpl int_p; + xml_schema::unsigned_int_pimpl unsigned_int_p; + xml_schema::long_pimpl long_p; + xml_schema::unsigned_long_pimpl unsigned_long_p; + + xml_schema::integer_pimpl integer_p; + xml_schema::negative_integer_pimpl negative_integer_p; + xml_schema::non_positive_integer_pimpl non_positive_integer_p; + xml_schema::positive_integer_pimpl positive_integer_p; + xml_schema::non_negative_integer_pimpl non_negative_integer_p; + + xml_schema::float_pimpl float_p; + xml_schema::double_pimpl double_p; + xml_schema::decimal_pimpl decimal_p; + + xml_schema::string_pimpl string_p; + xml_schema::normalized_string_pimpl normalized_string_p; + xml_schema::token_pimpl token_p; + xml_schema::name_pimpl name_p; + xml_schema::nmtoken_pimpl nmtoken_p; + xml_schema::nmtokens_pimpl nmtokens_p; + xml_schema::ncname_pimpl ncname_p; + xml_schema::id_pimpl id_p; + xml_schema::idref_pimpl idref_p; + xml_schema::idrefs_pimpl idrefs_p; + + xml_schema::language_pimpl language_p; + xml_schema::uri_pimpl uri_p; + xml_schema::qname_pimpl qname_p; + + xml_schema::base64_binary_pimpl base64_binary_p; + xml_schema::hex_binary_pimpl hex_binary_p; + + xml_schema::gday_pimpl gday_p; + xml_schema::gmonth_pimpl gmonth_p; + xml_schema::gyear_pimpl gyear_p; + xml_schema::gmonth_day_pimpl gmonth_day_p; + xml_schema::gyear_month_pimpl gyear_month_p; + xml_schema::date_pimpl date_p; + xml_schema::time_pimpl time_p; + xml_schema::date_time_pimpl date_time_p; + xml_schema::duration_pimpl duration_p; + + type_pimpl type_p; + + type_p.parsers (any_type_p, + any_simple_type_p, + boolean_p, + byte_p, + unsigned_byte_p, + short_p, + unsigned_short_p, + int_p, + unsigned_int_p, + long_p, + unsigned_long_p, + integer_p, + negative_integer_p, + non_positive_integer_p, + positive_integer_p, + non_negative_integer_p, + float_p, + double_p, + decimal_p, + string_p, + normalized_string_p, + token_p, + name_p, + nmtoken_p, + nmtokens_p, + ncname_p, + id_p, + idref_p, + idrefs_p, + language_p, + uri_p, + qname_p, + base64_binary_p, + hex_binary_p, + gday_p, + gmonth_p, + gyear_p, + gmonth_day_p, + gyear_month_p, + date_p, + time_p, + date_time_p, + duration_p); + + xml_schema::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/tests/cxx/parser/built-in/makefile b/tests/cxx/parser/built-in/makefile new file mode 100644 index 0000000..c38e16a --- /dev/null +++ b/tests/cxx/parser/built-in/makefile @@ -0,0 +1,75 @@ +# file : tests/cxx/parser/built-in/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) + diff --git a/tests/cxx/parser/built-in/output b/tests/cxx/parser/built-in/output new file mode 100644 index 0000000..756abcd --- /dev/null +++ b/tests/cxx/parser/built-in/output @@ -0,0 +1,164 @@ +{ + any attribute x = 'x' + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any-type' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any-type' + any text: ' + ' +} + +{ + any text: '123abc' +} + +1 +0 +1 +0 +0 +127 +-128 +123 +0 +255 +123 +0 +32767 +-32768 +-12345 +0 +65535 +12345 +0 +2147483647 +-2147483648 +-1234567890 +0 +4294967295 +1234567890 +0 +9223372036854775807 +-9223372036854775808 +-1234567890123456789 +0 +18446744073709551615 +12345678901234567890 +0 +2147483647 +-2147483648 +-1234567890 +-2147483648 +-1234567890 +0 +-2147483648 +-1234567890 +4294967295 +1234567890 +0 +4294967295 +1234567890 +0 +0 +-0 +inf +-inf +nan +123.567 +123.567 +-1.23567e+07 +-4.5e-06 +0 +0 +-0 +inf +-inf +nan +123.567 +123.567 +-1.23567e+07 +-4.5e-06 +0 +0 +-0 +123.567 +123.567 +-123.567 +'string space +newline + ' +' string space newline ' +'string space newline' +'as123:345-.abs' +'1as123:345-.abs' +'abc 123 ' +'as123_345-.abs' +'as123_345-.abs' +'abc' +'a123' +'as123_345-.abs' +'abc a123 ' +'x' +'en' +'en-us' +'one-two-three-four44-seven77-eight888' +'' +'relative' +'#id' +'http://www.example.com/foo#bar' +':schemaLocation' +'xsi:schemaLocation' +'12345abcjk' +'a' +'ab' +'abc' +'' +'12345abcjk' +12+12:0 +1 +31 +15+0:0 +15-14:0 +10+12:0 +1 +12+0:0 +2007+12:0 +1 +-20000+0:0 +10-28+12:0 +12-31 +1-1+0:0 +2007-12+12:0 +-2007-10 +20007-10+0:0 +-20007-1 +2007-12-26+12:0 +-2007-10-15 +20007-12-31+0:0 +-20007-1-1 +12:46:23.456+12:0 +12:13:14 +12:13:14+0:0 +2007-12-26T12:13:14.123+12:0 +-2007-10-15T12:13:14 +20007-12-31T12:13:14+0:0 +-20007-1-1T12:13:14 +-P2007Y13M32DT25H61M61.123S +P1Y0M0DT0H0M0S +P0Y1M0DT0H0M0S +P0Y0M1DT0H0M0S +P0Y0M0DT1H0M0S +P0Y0M0DT0H1M0S +P0Y0M0DT0H0M1.1S +P1Y0M0DT0H0M1S diff --git a/tests/cxx/parser/built-in/test.xml b/tests/cxx/parser/built-in/test.xml new file mode 100644 index 0000000..8d9332a --- /dev/null +++ b/tests/cxx/parser/built-in/test.xml @@ -0,0 +1,199 @@ + + + + a + aaabbbccc + + + 123abc + + 1 + 0 + true + false + + 0 + +127 + -128 + 123 + + 0 + 255 + 123 + + 0 + +32767 + -32768 + -12345 + + 0 + 65535 + 12345 + + 0 + +2147483647 + -2147483648 + -1234567890 + + 0 + 4294967295 + 1234567890 + + 0 + +9223372036854775807 + -9223372036854775808 + -1234567890123456789 + + 0 + 18446744073709551615 + 12345678901234567890 + + 0 + +2147483647 + -02147483648 + -1234567890 + + -02147483648 + -1234567890 + + 0 + -02147483648 + -1234567890 + + 4294967295 + +01234567890 + + 0 + 4294967295 + +01234567890 + + 0 + +0 + -0 + INF + -INF + NaN + 123.567 + +123.567 + -123.567e5 + -.45E-5 + + 0 + +0 + -0 + INF + -INF + NaN + 123.567 + +123.567 + -123.567e5 + -.45E-5 + + 0 + +0 + -0 + 123.567 + +123.567 + -123.567 + + string space +newline + + + string space +newline + + + + string space +newline + + + + as123:345-.abs + + 1as123:345-.abs + + abc 123 + + as123_345-.abs + + as123_345-.abs + abc + a123 + + as123_345-.abs + + abc a123 + + x + en + en-us + one-two-three-four44-seven77-eight888 + + + relative + #id + http://www.example.com/foo#bar + + schemaLocation + xsi:schemaLocation + + MTIzND + VhYmNqaw = = + YQ== + YWI= + YWJj + + + 31323334356162636a6b + + ---12+12:00 + ---01 + ---31 + ---15Z + ---15-14:00 + + --10+12:00 + --01 + --12Z + + 2007+12:00 + 0001 + -20000Z + + --10-28+12:00 + --12-31 + --01-01Z + + 2007-12+12:00 + -2007-10 + 20007-10Z + -20007-01 + + 2007-12-26+12:00 + -2007-10-15 + 20007-12-31Z + -20007-01-01 + + + + + + 2007-12-26T12:13:14.123+12:00 + -2007-10-15T12:13:14 + 20007-12-31T12:13:14Z + -20007-01-01T12:13:14 + + -P2007Y13M32DT25H61M61.123S + P1Y + P1M + P1D + PT1H + PT1M + PT1.1S + P1YT1S + + diff --git a/tests/cxx/parser/built-in/test.xsd b/tests/cxx/parser/built-in/test.xsd new file mode 100644 index 0000000..9c00eb4 --- /dev/null +++ b/tests/cxx/parser/built-in/test.xsd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/enumeration/driver.cxx b/tests/cxx/parser/enumeration/driver.cxx new file mode 100644 index 0000000..056df76 --- /dev/null +++ b/tests/cxx/parser/enumeration/driver.cxx @@ -0,0 +1,83 @@ +// file : tests/cxx/parser/enumeration/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// 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/tests/cxx/parser/enumeration/gender.hxx b/tests/cxx/parser/enumeration/gender.hxx new file mode 100644 index 0000000..be74b4a --- /dev/null +++ b/tests/cxx/parser/enumeration/gender.hxx @@ -0,0 +1,15 @@ +// file : tests/cxx/parser/enumeration/gender.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// 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/tests/cxx/parser/enumeration/makefile b/tests/cxx/parser/enumeration/makefile new file mode 100644 index 0000000..0376d1a --- /dev/null +++ b/tests/cxx/parser/enumeration/makefile @@ -0,0 +1,75 @@ +# file : tests/cxx/parser/enumeration/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --type-map $(src_base)/test.map +$(skel): $(out_root)/xsd/xsd $(src_base)/test.map + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/enumeration/output b/tests/cxx/parser/enumeration/output new file mode 100644 index 0000000..16db301 --- /dev/null +++ b/tests/cxx/parser/enumeration/output @@ -0,0 +1,3 @@ +1 +0 +1 diff --git a/tests/cxx/parser/enumeration/test.map b/tests/cxx/parser/enumeration/test.map new file mode 100644 index 0000000..f8868d6 --- /dev/null +++ b/tests/cxx/parser/enumeration/test.map @@ -0,0 +1,7 @@ +namespace test +{ + include "gender.hxx"; + + digit int int; + gender ::gender ::gender; +} diff --git a/tests/cxx/parser/enumeration/test.xml b/tests/cxx/parser/enumeration/test.xml new file mode 100644 index 0000000..a6fa893 --- /dev/null +++ b/tests/cxx/parser/enumeration/test.xml @@ -0,0 +1,10 @@ + + + 1 + + male + female + + diff --git a/tests/cxx/parser/enumeration/test.xsd b/tests/cxx/parser/enumeration/test.xsd new file mode 100644 index 0000000..ded3a18 --- /dev/null +++ b/tests/cxx/parser/enumeration/test.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/generated-impl/makefile b/tests/cxx/parser/generated-impl/makefile new file mode 100644 index 0000000..71f94ab --- /dev/null +++ b/tests/cxx/parser/generated-impl/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/parser/generated-impl/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := test.xsd + +obj := $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.o) $(xsd:.xsd=-pimpl.o) $(xsd:.xsd=-driver.o)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/$(xsd:.xsd=-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) + +gen := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.hxx) \ + $(out_base)/$(xsd:.xsd=-pimpl.cxx) \ + $(out_base)/$(xsd:.xsd=-driver.cxx) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-print-impl --generate-test-driver \ +--force-overwrite +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pimpl.cxx.xsd.clean)) + + +# 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) + +xsd_parser_impl_suffix := -pimpl +$(call include,$(scf_root)/xsd/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/generated-impl/output b/tests/cxx/parser/generated-impl/output new file mode 100644 index 0000000..7c58647 --- /dev/null +++ b/tests/cxx/parser/generated-impl/output @@ -0,0 +1,122 @@ +gender: male +foo: foo +gender: male +int: 0 +int: 1 +int: 2 +int: 3 +foo: foo +int: 3 +int: 2 +int: 1 +int: 0 +union: 9 +foo: foo +union: string +x: x +a: aaa +x: x +y: y +a: aaa +b: bbb +boolean: 1 +boolean: 0 +boolean: 1 +boolean: 0 +byte: 0 +byte: 123 +byte: -123 +unsigned-byte: 0 +unsigned-byte: 123 +short: 0 +short: -1234 +short: 1234 +unsigned-short: 0 +unsigned-short: 1234 +int: 0 +int: -12345 +int: 12345 +unsigned-int: 0 +unsigned-int: 12345 +long: 0 +long: -123456 +long: 123456 +unsigned-long: 0 +unsigned-long: 123456 +integer: 0 +integer: -123456 +integer: 123456 +negative-integer: -123456 +non-positive-integer: 0 +non-positive-integer: -123456 +positive-integer: 123456 +non-negative-integer: 0 +non-negative-integer: 123456 +float: 0 +float: 1.123 +float: -1.123 +double: 0 +double: 1.1234 +double: -1.1234 +decimal: 0 +decimal: 1.1234 +decimal: -1.1234 +string: string space newline +normalized-string: string space newline +token: string space newline +name: as123:345-.abs +nmtoken: 1as123:345-.abs +nmtokens: abc 123 +ncname: as123_345-.abs +id: abc +id: a123 +idref: abc +idrefs: abc a123 +language: en +language: en-us +uri: http://www.example.com/foo#bar +qname: schemaLocation +qname: xsi:schemaLocation +base64_binary: 10 bytes +base64_binary: 1 bytes +base64_binary: 2 bytes +base64_binary: 3 bytes +hex_binary: 0 bytes +hex_binary: 10 bytes +gday: ---12+12:0 +gday: ---1 +gday: ---31 +gday: ---15+0:0 +gday: ---15-14:0 +gmonth: --10+12:0 +gmonth: --1 +gmonth: --12+0:0 +gyear: 2007+12:0 +gyear: 1 +gyear: -20000+0:0 +gmonth_day: --10-28+12:0 +gmonth_day: --12-31 +gmonth_day: --1-1+0:0 +gyear_month: 2007-12+12:0 +gyear_month: -2007-10 +gyear_month: 20007-10+0:0 +gyear_month: -20007-1 +date: 2007-12-26+12:0 +date: -2007-10-15 +date: 20007-12-31+0:0 +date: -20007-1-1 +time: 12:46:23.456+12:0 +time: 12:13:14 +time: 12:13:14+0:0 +date_time: 2007-12-26T12:13:14.123+12:0 +date_time: -2007-10-15T12:13:14 +date_time: 20007-12-31T12:13:14+0:0 +date_time: -20007-1-1T12:13:14 +duration: -P2007Y13M32DT25H61M61.123S +duration: P1Y0M0DT0H0M0S +duration: P0Y1M0DT0H0M0S +duration: P0Y0M1DT0H0M0S +duration: P0Y0M0DT1H0M0S +duration: P0Y0M0DT0H1M0S +duration: P0Y0M0DT0H0M1.1S +duration: P1Y0M0DT0H0M1S diff --git a/tests/cxx/parser/generated-impl/test.xml b/tests/cxx/parser/generated-impl/test.xml new file mode 100644 index 0000000..2f29a39 --- /dev/null +++ b/tests/cxx/parser/generated-impl/test.xml @@ -0,0 +1,168 @@ + + + male + male + + 0 1 2 3 + 3 2 1 0 + + 9 + string + + + aaa + + + + aaa + bbb + + + aaabbbccc + abc123 + + 1 + 0 + true + false + + 0 + 123 + -123 + + 0 + 123 + + 0 + -1234 + 1234 + + 0 + 1234 + + 0 + -12345 + 12345 + + 0 + 12345 + + 0 + -123456 + 123456 + + 0 + 123456 + + 0 + -123456 + 123456 + + -123456 + + 0 + -123456 + + 123456 + + 0 + 123456 + + 0 + 1.123 + -1.123 + + 0 + 1.1234 + -1.1234 + + 0 + 1.1234 + -1.1234 + + string space newline + + string space newline + + string space newline + + as123:345-.abs + + 1as123:345-.abs + + abc 123 + + as123_345-.abs + + abc + a123 + + abc + + abc a123 + + en + en-us + + http://www.example.com/foo#bar + + schemaLocation + xsi:schemaLocation + + MTIzNDVhYmNqaw== + YQ== + YWI= + YWJj + + + 31323334356162636a6b + + ---12+12:00 + ---01 + ---31 + ---15Z + ---15-14:00 + + --10+12:00 + --01 + --12Z + + 2007+12:00 + 0001 + -20000Z + + --10-28+12:00 + --12-31 + --01-01Z + + 2007-12+12:00 + -2007-10 + 20007-10Z + -20007-01 + + 2007-12-26+12:00 + -2007-10-15 + 20007-12-31Z + -20007-01-01 + + + + + + 2007-12-26T12:13:14.123+12:00 + -2007-10-15T12:13:14 + 20007-12-31T12:13:14Z + -20007-01-01T12:13:14 + + -P2007Y13M32DT25H61M61.123S + P1Y + P1M + P1D + PT1H + PT1M + PT1.1S + P1YT1S + + diff --git a/tests/cxx/parser/generated-impl/test.xsd b/tests/cxx/parser/generated-impl/test.xsd new file mode 100644 index 0000000..7bc8f23 --- /dev/null +++ b/tests/cxx/parser/generated-impl/test.xsd @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/list/driver.cxx b/tests/cxx/parser/list/driver.cxx new file mode 100644 index 0000000..531ad94 --- /dev/null +++ b/tests/cxx/parser/list/driver.cxx @@ -0,0 +1,107 @@ +// file : tests/cxx/parser/list/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:list parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct string_list_pimpl: string_list_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + item (string const& v) + { + cout << " '" << v << "'" << endl; + } + + virtual void + post_string_list () + { + cout << "}" << endl + << endl; + } +}; + +struct string_list_lang_pimpl: string_list_lang_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + item (string const& v) + { + cout << " '" << v << "'" << endl; + } + + virtual void + lang (string const& v) + { + cout << " lang: '" << v << "'" << endl; + } + + virtual void + post_string_list_lang () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + string_list_pimpl string_list_p; + string_list_lang_pimpl string_list_lang_p; + type_pimpl type_p; + + string_list_p.parsers (string_p); + string_list_lang_p.parsers (string_p, string_p); + type_p.parsers (string_list_p, string_list_lang_p); + + xml_schema::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 (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/list/makefile b/tests/cxx/parser/list/makefile new file mode 100644 index 0000000..c86fc31 --- /dev/null +++ b/tests/cxx/parser/list/makefile @@ -0,0 +1,74 @@ +# file : tests/cxx/parser/list/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/list/output b/tests/cxx/parser/list/output new file mode 100644 index 0000000..3642c4d --- /dev/null +++ b/tests/cxx/parser/list/output @@ -0,0 +1,26 @@ +{ +} + +{ +} + +{ +} + +{ + 'one' +} + +{ + 'one' + 'two' + 'three' +} + +{ + lang: 'en' + 'one' + 'two' + 'three' +} + diff --git a/tests/cxx/parser/list/test.xml b/tests/cxx/parser/list/test.xml new file mode 100644 index 0000000..52229db --- /dev/null +++ b/tests/cxx/parser/list/test.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + one + + + one two + three + + + + one two + three + + + diff --git a/tests/cxx/parser/list/test.xsd b/tests/cxx/parser/list/test.xsd new file mode 100644 index 0000000..79bd084 --- /dev/null +++ b/tests/cxx/parser/list/test.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/makefile b/tests/cxx/parser/makefile new file mode 100644 index 0000000..955be44 --- /dev/null +++ b/tests/cxx/parser/makefile @@ -0,0 +1,24 @@ +# file : tests/cxx/parser/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + + +tests := built-in enumeration generated-impl list recursive \ +name-clash/inheritance polymorphism test-template validation \ +union + + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/parser/name-clash/inheritance/driver.cxx b/tests/cxx/parser/name-clash/inheritance/driver.cxx new file mode 100644 index 0000000..86b2746 --- /dev/null +++ b/tests/cxx/parser/name-clash/inheritance/driver.cxx @@ -0,0 +1,64 @@ +// file : tests/cxx/parser/name-clash/inheritance/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test for name clashes across inheritance hierarchy. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct derived_pimpl: derived_pskel +{ + virtual void + e (string const& v) + { + cout << "e: " << v << endl; + } + + virtual void + e1 (string const& v) + { + cout << "e1: " << v << endl; + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + derived_pimpl derived_p; + + derived_p.parsers (string_p, string_p); + + xml_schema::document doc_p (derived_p, "test", "root"); + + derived_p.pre (); + doc_p.parse (argv[1]); + derived_p.post_derived (); + } + 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/tests/cxx/parser/name-clash/inheritance/makefile b/tests/cxx/parser/name-clash/inheritance/makefile new file mode 100644 index 0000000..1d530d7 --- /dev/null +++ b/tests/cxx/parser/name-clash/inheritance/makefile @@ -0,0 +1,75 @@ +# file : tests/cxx/parser/name-clash/inheritance/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/name-clash/inheritance/output b/tests/cxx/parser/name-clash/inheritance/output new file mode 100644 index 0000000..4efd51b --- /dev/null +++ b/tests/cxx/parser/name-clash/inheritance/output @@ -0,0 +1,2 @@ +e: e +e1: e1 diff --git a/tests/cxx/parser/name-clash/inheritance/test.xml b/tests/cxx/parser/name-clash/inheritance/test.xml new file mode 100644 index 0000000..8c17101 --- /dev/null +++ b/tests/cxx/parser/name-clash/inheritance/test.xml @@ -0,0 +1,8 @@ + + + e + e1 + + diff --git a/tests/cxx/parser/name-clash/inheritance/test.xsd b/tests/cxx/parser/name-clash/inheritance/test.xsd new file mode 100644 index 0000000..62a782e --- /dev/null +++ b/tests/cxx/parser/name-clash/inheritance/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/polymorphism/makefile b/tests/cxx/parser/polymorphism/makefile new file mode 100644 index 0000000..a3c4f3e --- /dev/null +++ b/tests/cxx/parser/polymorphism/makefile @@ -0,0 +1,22 @@ +# file : tests/cxx/parser/polymorphism/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + + +tests := same-type + + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/parser/polymorphism/same-type/driver.cxx b/tests/cxx/parser/polymorphism/same-type/driver.cxx new file mode 100644 index 0000000..0607ff9 --- /dev/null +++ b/tests/cxx/parser/polymorphism/same-type/driver.cxx @@ -0,0 +1,64 @@ +// file : tests/cxx/parser/polymorphism/same-type/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test substitution group and xsi:type that don't change the type. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_pimpl: base_pskel +{ + virtual void + a (string const& v) + { + cout << v << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + base_pimpl base_p; + type_pimpl type_p; + + base_p.parsers (string_p); + type_p.parsers (base_p); + + xml_schema::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/tests/cxx/parser/polymorphism/same-type/makefile b/tests/cxx/parser/polymorphism/same-type/makefile new file mode 100644 index 0000000..5fb28b1 --- /dev/null +++ b/tests/cxx/parser/polymorphism/same-type/makefile @@ -0,0 +1,75 @@ +# file : tests/cxx/parser/polymorphism/same-type/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-polymorphic +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/polymorphism/same-type/output b/tests/cxx/parser/polymorphism/same-type/output new file mode 100644 index 0000000..d418277 --- /dev/null +++ b/tests/cxx/parser/polymorphism/same-type/output @@ -0,0 +1,4 @@ +a1 +a2 +a3 +a4 diff --git a/tests/cxx/parser/polymorphism/same-type/test.xml b/tests/cxx/parser/polymorphism/same-type/test.xml new file mode 100644 index 0000000..f8b6d1e --- /dev/null +++ b/tests/cxx/parser/polymorphism/same-type/test.xml @@ -0,0 +1,10 @@ + + + a1 + a2 + a3 + a4 + + diff --git a/tests/cxx/parser/polymorphism/same-type/test.xsd b/tests/cxx/parser/polymorphism/same-type/test.xsd new file mode 100644 index 0000000..a4157d3 --- /dev/null +++ b/tests/cxx/parser/polymorphism/same-type/test.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/recursive/driver.cxx b/tests/cxx/parser/recursive/driver.cxx new file mode 100644 index 0000000..db74cc6 --- /dev/null +++ b/tests/cxx/parser/recursive/driver.cxx @@ -0,0 +1,141 @@ +// file : tests/cxx/parser/recursive/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test recursive parser invocation. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; + +struct sub_pimpl: sub_type_pskel +{ + virtual void + pre () + { + cout << "sub::pre" << endl; + } + + virtual void + sub () + { + cout << "sub::sub" << endl; + } + + virtual void + sub2 () + { + cout << "sub::sub2" << endl; + } + + virtual void + name (string const& n) + { + cout << "sub::name: " << n << endl; + } + + virtual void + post_sub_type () + { + cout << "sub::post" << endl; + } +}; + +struct indir_pimpl: indir_type_pskel +{ + virtual void + pre () + { + cout << "indir::pre" << endl; + } + + virtual void + sub () + { + cout << "indir::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "indir::name: " << n << endl; + } + + virtual void + post_indir_type () + { + cout << "indir::post" << endl; + } +}; + +struct test_pimpl: test_type_pskel +{ + virtual void + pre () + { + cout << "test::pre" << endl; + } + + virtual void + sub () + { + cout << "test::sub" << endl; + } + + virtual void + name (string const& n) + { + cout << "test::name: " << n << endl; + } + + virtual void + post_test_type () + { + cout << "test::post" << endl; + } +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + + sub_pimpl sub_p; + indir_pimpl indir_p; + test_pimpl test_p; + + sub_p.parsers (sub_p, indir_p, sub_p, string_p); + indir_p.parsers (sub_p, string_p); + test_p.parsers (sub_p, string_p); + + xml_schema::document doc_p (test_p, "test"); + + test_p.pre (); + doc_p.parse (argv[1]); + test_p.post_test_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/recursive/makefile b/tests/cxx/parser/recursive/makefile new file mode 100644 index 0000000..20b4599 --- /dev/null +++ b/tests/cxx/parser/recursive/makefile @@ -0,0 +1,75 @@ +# file : tests/cxx/parser/recursive/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/recursive/output b/tests/cxx/parser/recursive/output new file mode 100644 index 0000000..f26fb72 --- /dev/null +++ b/tests/cxx/parser/recursive/output @@ -0,0 +1,22 @@ +test::pre +test::name: testName +sub::pre +sub::name: subName +sub::pre +sub::name: sub-subName +sub::post +sub::sub +indir::pre +indir::name: sub-indirName +sub::pre +sub::name: sub-indir-subName +sub::post +indir::sub +indir::post +sub::pre +sub::name: sub-sub2Name +sub::post +sub::sub2 +sub::post +test::sub +test::post diff --git a/tests/cxx/parser/recursive/test.xml b/tests/cxx/parser/recursive/test.xml new file mode 100644 index 0000000..f6c219d --- /dev/null +++ b/tests/cxx/parser/recursive/test.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/tests/cxx/parser/recursive/test.xsd b/tests/cxx/parser/recursive/test.xsd new file mode 100644 index 0000000..33e1d2d --- /dev/null +++ b/tests/cxx/parser/recursive/test.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/test-template/driver.cxx b/tests/cxx/parser/test-template/driver.cxx new file mode 100644 index 0000000..aa14601 --- /dev/null +++ b/tests/cxx/parser/test-template/driver.cxx @@ -0,0 +1,68 @@ +// file : tests/cxx/parser/test-template/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct type_pimpl: type_pskel +{ + virtual void + pre () + { + } + + virtual void + a (string const& v) + { + cout << v << endl; + } + + virtual void + post_type () + { + } +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + type_pimpl type_p; + + type_p.parsers (string_p); + + xml_schema::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/tests/cxx/parser/test-template/makefile b/tests/cxx/parser/test-template/makefile new file mode 100644 index 0000000..3b6855a --- /dev/null +++ b/tests/cxx/parser/test-template/makefile @@ -0,0 +1,74 @@ +# file : tests/cxx/parser/test-template/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/test-template/output b/tests/cxx/parser/test-template/output new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/tests/cxx/parser/test-template/output @@ -0,0 +1 @@ +a diff --git a/tests/cxx/parser/test-template/test.xml b/tests/cxx/parser/test-template/test.xml new file mode 100644 index 0000000..624a80c --- /dev/null +++ b/tests/cxx/parser/test-template/test.xml @@ -0,0 +1,7 @@ + + + a + + diff --git a/tests/cxx/parser/test-template/test.xsd b/tests/cxx/parser/test-template/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/tests/cxx/parser/test-template/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/cxx/parser/union/driver.cxx b/tests/cxx/parser/union/driver.cxx new file mode 100644 index 0000000..765f06a --- /dev/null +++ b/tests/cxx/parser/union/driver.cxx @@ -0,0 +1,62 @@ +// file : tests/cxx/parser/union/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test xsd:union parsing. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct int_string_union_pimpl: int_string_union_pskel +{ + virtual void + _characters (const xml_schema::ro_string& s) + { + cout << "'" << s << "'" << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + int_string_union_pimpl int_string_union_p; + type_pimpl type_p; + + type_p.parsers (int_string_union_p); + + xml_schema::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/tests/cxx/parser/union/makefile b/tests/cxx/parser/union/makefile new file mode 100644 index 0000000..0e186b7 --- /dev/null +++ b/tests/cxx/parser/union/makefile @@ -0,0 +1,74 @@ +# file : tests/cxx/parser/union/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/union/output b/tests/cxx/parser/union/output new file mode 100644 index 0000000..a92ffc3 --- /dev/null +++ b/tests/cxx/parser/union/output @@ -0,0 +1,2 @@ +'one' +'1' diff --git a/tests/cxx/parser/union/test.xml b/tests/cxx/parser/union/test.xml new file mode 100644 index 0000000..5b3e799 --- /dev/null +++ b/tests/cxx/parser/union/test.xml @@ -0,0 +1,10 @@ + + + + + one + 1 + + diff --git a/tests/cxx/parser/union/test.xsd b/tests/cxx/parser/union/test.xsd new file mode 100644 index 0000000..5bf3d47 --- /dev/null +++ b/tests/cxx/parser/union/test.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/all/driver.cxx b/tests/cxx/parser/validation/all/driver.cxx new file mode 100644 index 0000000..a5ad1cf --- /dev/null +++ b/tests/cxx/parser/validation/all/driver.cxx @@ -0,0 +1,100 @@ +// file : tests/cxx/parser/validation/all/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the all compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct all_pimpl: all_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + post_all () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + all_pimpl all_p; + type_pimpl type_p; + + all_p.parsers (string_p, string_p, string_p); + type_p.parsers (all_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/all/makefile b/tests/cxx/parser/validation/all/makefile new file mode 100644 index 0000000..7295256 --- /dev/null +++ b/tests/cxx/parser/validation/all/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/all/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 001 002 003 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/all/test-000.std b/tests/cxx/parser/validation/all/test-000.std new file mode 100644 index 0000000..b4445f2 --- /dev/null +++ b/tests/cxx/parser/validation/all/test-000.std @@ -0,0 +1,46 @@ +{ + a = a + b = b + c = c +} + +{ + a = a + c = c + b = b +} + +{ + b = b + a = a + c = c +} + +{ + b = b + c = c + a = a +} + +{ + c = c + a = a + b = b +} + +{ + c = c + b = b + a = a +} + +{ + a = a + b = b +} + +{ + a = a + b = b +} + diff --git a/tests/cxx/parser/validation/all/test-000.xml b/tests/cxx/parser/validation/all/test-000.xml new file mode 100644 index 0000000..6e46fae --- /dev/null +++ b/tests/cxx/parser/validation/all/test-000.xml @@ -0,0 +1,53 @@ + + + + + a + b + c + + + + a + c + b + + + + b + a + c + + + + b + c + a + + + + c + a + b + + + + c + b + a + + + + + a + b + + + + a + b + + + diff --git a/tests/cxx/parser/validation/all/test-001.std b/tests/cxx/parser/validation/all/test-001.std new file mode 100644 index 0000000..0472ad9 --- /dev/null +++ b/tests/cxx/parser/validation/all/test-001.std @@ -0,0 +1,6 @@ +{ + a = a + c = c + :9:9 error: expected element 'b' +} + diff --git a/tests/cxx/parser/validation/all/test-001.xml b/tests/cxx/parser/validation/all/test-001.xml new file mode 100644 index 0000000..3df5600 --- /dev/null +++ b/tests/cxx/parser/validation/all/test-001.xml @@ -0,0 +1,11 @@ + + + + + a + c + + + diff --git a/tests/cxx/parser/validation/all/test-002.std b/tests/cxx/parser/validation/all/test-002.std new file mode 100644 index 0000000..c014230 --- /dev/null +++ b/tests/cxx/parser/validation/all/test-002.std @@ -0,0 +1,4 @@ +{ + :7:9 error: expected element 'a' +} + diff --git a/tests/cxx/parser/validation/all/test-002.xml b/tests/cxx/parser/validation/all/test-002.xml new file mode 100644 index 0000000..aed0c0c --- /dev/null +++ b/tests/cxx/parser/validation/all/test-002.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/tests/cxx/parser/validation/all/test-003.std b/tests/cxx/parser/validation/all/test-003.std new file mode 100644 index 0000000..dd8c0d3 --- /dev/null +++ b/tests/cxx/parser/validation/all/test-003.std @@ -0,0 +1,6 @@ +{ + a = a + b = b + :9:7 error: unexpected element 'a' +} + diff --git a/tests/cxx/parser/validation/all/test-003.xml b/tests/cxx/parser/validation/all/test-003.xml new file mode 100644 index 0000000..b147cba --- /dev/null +++ b/tests/cxx/parser/validation/all/test-003.xml @@ -0,0 +1,12 @@ + + + + + a + b + a + + + diff --git a/tests/cxx/parser/validation/all/test.xsd b/tests/cxx/parser/validation/all/test.xsd new file mode 100644 index 0000000..1f670e3 --- /dev/null +++ b/tests/cxx/parser/validation/all/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/any/driver.cxx b/tests/cxx/parser/validation/any/driver.cxx new file mode 100644 index 0000000..956bc7a --- /dev/null +++ b/tests/cxx/parser/validation/any/driver.cxx @@ -0,0 +1,123 @@ +// file : tests/cxx/parser/validation/any/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the any particle validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_a_pimpl: any_a_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + x (string const& v) + { + cout << " x = " << v << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_a () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + any_a_pimpl any_a_p; + type_pimpl type_p; + + any_a_p.parsers (string_p, string_p); + type_p.parsers (any_a_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/any/makefile b/tests/cxx/parser/validation/any/makefile new file mode 100644 index 0000000..76d8618 --- /dev/null +++ b/tests/cxx/parser/validation/any/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/any/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/any/test-000.std b/tests/cxx/parser/validation/any/test-000.std new file mode 100644 index 0000000..a1cc6e3 --- /dev/null +++ b/tests/cxx/parser/validation/any/test-000.std @@ -0,0 +1,29 @@ +{ + start any element 'any' + end any element 'any' +} + +{ + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + +{ + x = x + a = a + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' +} + diff --git a/tests/cxx/parser/validation/any/test-000.xml b/tests/cxx/parser/validation/any/test-000.xml new file mode 100644 index 0000000..f1a0c83 --- /dev/null +++ b/tests/cxx/parser/validation/any/test-000.xml @@ -0,0 +1,21 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + diff --git a/tests/cxx/parser/validation/any/test.xsd b/tests/cxx/parser/validation/any/test.xsd new file mode 100644 index 0000000..c05aeb5 --- /dev/null +++ b/tests/cxx/parser/validation/any/test.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/attribute/driver.cxx b/tests/cxx/parser/validation/attribute/driver.cxx new file mode 100644 index 0000000..b49af04 --- /dev/null +++ b/tests/cxx/parser/validation/attribute/driver.cxx @@ -0,0 +1,199 @@ +// file : tests/cxx/parser/validation/attribute/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test attribute and attribute wildcard (anyAttribute) validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct pass_a_pimpl: pass_a_pskel +{ + virtual void + pre () + { + cout << "pass-a" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + _any_attribute (ro_string const& ns, + ro_string const& name, + ro_string const& value) + { + cout << " any: " << ns << "#" << name << " = " << value << endl; + } + + virtual void + post_pass_a () + { + cout << "}" << endl + << endl; + } +}; + +struct pass_b_pimpl: pass_b_pskel +{ + virtual void + pre () + { + cout << "pass-b" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + _any_attribute (ro_string const& ns, + ro_string const& name, + ro_string const& value) + { + cout << " any: " << ns << "#" << name << " = " << value << endl; + } + + virtual void + post_pass_b () + { + cout << "}" << endl + << endl; + } +}; + +struct pass_c_pimpl: pass_c_pskel +{ + virtual void + pre () + { + cout << "pass-c" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + post_pass_c () + { + cout << "}" << endl + << endl; + } +}; + +struct fail_pimpl: fail_pskel +{ + virtual void + pre () + { + cout << "fail" << endl + << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + post_fail () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + pass_a_pimpl pass_a_p; + pass_b_pimpl pass_b_p; + pass_c_pimpl pass_c_p; + fail_pimpl fail_p; + type_pimpl type_p; + + pass_a_p.parsers (string_p, string_p); + pass_b_p.parsers (string_p, string_p); + pass_c_p.parsers (string_p, string_p); + fail_p.parsers (string_p); + type_p.parsers (pass_a_p, pass_b_p, pass_c_p, fail_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/attribute/makefile b/tests/cxx/parser/validation/attribute/makefile new file mode 100644 index 0000000..281d174 --- /dev/null +++ b/tests/cxx/parser/validation/attribute/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/attribute/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/attribute/test-000.std b/tests/cxx/parser/validation/attribute/test-000.std new file mode 100644 index 0000000..847b054 --- /dev/null +++ b/tests/cxx/parser/validation/attribute/test-000.std @@ -0,0 +1,24 @@ +pass-a +{ + b = b + any: test#foo = foo + any: test#bar = bar +} + +pass-b +{ + a = a + b = b +} + +pass-c +{ + a = a + b = b +} + +fail +{ + :8:10 error: expected attribute 'a' +} + diff --git a/tests/cxx/parser/validation/attribute/test-000.xml b/tests/cxx/parser/validation/attribute/test-000.xml new file mode 100644 index 0000000..b994d1a --- /dev/null +++ b/tests/cxx/parser/validation/attribute/test-000.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/tests/cxx/parser/validation/attribute/test.xsd b/tests/cxx/parser/validation/attribute/test.xsd new file mode 100644 index 0000000..833eb8e --- /dev/null +++ b/tests/cxx/parser/validation/attribute/test.xsd @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/built-in/any-type/driver.cxx b/tests/cxx/parser/validation/built-in/any-type/driver.cxx new file mode 100644 index 0000000..3381d94 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/any-type/driver.cxx @@ -0,0 +1,156 @@ +// file : tests/cxx/parser/validation/built-in/any-type/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the anyType and anySimpleType validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct any_type_pimpl: xml_schema::any_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _start_any_element (ro_string const&, + ro_string const& n, + ro_string const*) + { + cout << " start any element '" << n << "'" << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const& n) + { + cout << " end any element '" << n << "'" << endl; + } + + virtual void + _any_attribute (ro_string const&, + ro_string const& n, + ro_string const& v) + { + cout << " any attribute " << n << " = '" << v << "'" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_simple_type_pimpl: xml_schema::any_simple_type_pimpl +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + _any_characters (ro_string const& s) + { + cout << " any text: '" << s << "'" << endl; + } + + virtual void + post_any_simple_type () + { + cout << "}" << endl + << endl; + } +}; + +struct any_extension_pimpl: virtual any_extension_pskel, + any_type_pimpl + +{ + virtual void + x (const string& v) + { + cout << " x = " << v << endl; + } +}; + +struct any_simple_extension_pimpl: virtual any_simple_extension_pskel, + any_simple_type_pimpl +{ + virtual void + x (const string& v) + { + cout << " x = " << v << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + + any_type_pimpl any_type_p; + any_simple_type_pimpl any_simple_type_p; + + any_extension_pimpl any_extension_p; + any_simple_extension_pimpl any_simple_extension_p; + + type_pimpl type_p; + + any_extension_p.parsers (string_p); + any_simple_extension_p.parsers (string_p); + + type_p.parsers (any_type_p, + any_extension_p, + any_simple_extension_p, + any_simple_type_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/built-in/any-type/makefile b/tests/cxx/parser/validation/built-in/any-type/makefile new file mode 100644 index 0000000..613eb35 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/any-type/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/built-in/any-type/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.std b/tests/cxx/parser/validation/built-in/any-type/test-000.std new file mode 100644 index 0000000..84d7b3a --- /dev/null +++ b/tests/cxx/parser/validation/built-in/any-type/test-000.std @@ -0,0 +1,99 @@ +{ + any text: '123abc' +} + +{ + any text: ' + ' + start any element 'any' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + any attribute x = 'x' + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + end any element 'any' + any text: ' + ' +} + +{ + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + x = x + any text: ' + ' + start any element 'a' + any text: 'a' + end any element 'a' + any text: ' + ' + start any element 'any' + any attribute x = 'xxx' + any text: 'aaa' + start any element 'a' + any text: 'bbb' + end any element 'a' + any text: 'ccc' + end any element 'any' + any text: ' + ' +} + +{ + x = x + any text: 'abc123' +} + diff --git a/tests/cxx/parser/validation/built-in/any-type/test-000.xml b/tests/cxx/parser/validation/built-in/any-type/test-000.xml new file mode 100644 index 0000000..7875b7e --- /dev/null +++ b/tests/cxx/parser/validation/built-in/any-type/test-000.xml @@ -0,0 +1,41 @@ + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + + + + + + aaabbbccc + + + + a + aaabbbccc + + + + + abc123 + + diff --git a/tests/cxx/parser/validation/built-in/any-type/test.xsd b/tests/cxx/parser/validation/built-in/any-type/test.xsd new file mode 100644 index 0000000..86a4e13 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/any-type/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/built-in/binary/driver.cxx b/tests/cxx/parser/validation/built-in/binary/driver.cxx new file mode 100644 index 0000000..a3885c8 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/binary/driver.cxx @@ -0,0 +1,155 @@ +// file : tests/cxx/parser/validation/built-in/binary/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in base64Binary and hexBinary types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::buffer buffer; + + // Good. + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters (" "); + p._post (); + assert (*p.post_hex_binary () == buffer ()); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n313"); + p._characters ("23334356162636a6b "); + p._post (); + assert (*p.post_hex_binary () == buffer ("12345abcjk", 10)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("MTIzND "); + p._characters ("VhYmNqaw = = "); + p._post (); + assert (*p.post_base64_binary () == buffer ("12345abcjk", 10)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ=="); + p._post (); + assert (*p.post_base64_binary () == buffer ("a", 1)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWI="); + p._post (); + assert (*p.post_base64_binary () == buffer ("ab", 2)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YWJj"); + p._post (); + assert (*p.post_base64_binary () == buffer ("abc", 3)); + } + + // Bad + // + + // hexBinary + // + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313"); + assert (test_post_fail (p)); + } + + { + hex_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("313233343X6162636a6b"); + assert (test_post_fail (p)); + } + + // base64Binary + // + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("YQ"); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("=="); + assert (test_post_fail (p)); + } + + { + base64_binary_pimpl p; + p.pre (); + p._pre (); + p._characters ("MTIzNDVhYmNqaw=A"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/binary/makefile b/tests/cxx/parser/validation/built-in/binary/makefile new file mode 100644 index 0000000..1a62471 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/binary/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/binary/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/boolean/driver.cxx b/tests/cxx/parser/validation/built-in/boolean/driver.cxx new file mode 100644 index 0000000..72a1356 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/boolean/driver.cxx @@ -0,0 +1,147 @@ +// file : tests/cxx/parser/validation/built-in/boolean/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in boolean type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (boolean_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("true"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("false"); + p._post (); + assert (!p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (!p.post_boolean ()); + } + + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" true "); + p._post (); + assert (p.post_boolean ()); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \n "); + p._characters (" fa"); + p._characters ("l"); + p._characters ("se "); + p._characters (" \n "); + p._characters (" "); + p._post (); + assert (!p.post_boolean ()); + } + + // Bad + // + { + boolean_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("fal"); + p._characters ("s "); + p._characters ("e"); + assert (test_post_fail (p)); + } + + { + boolean_pimpl p; + p.pre (); + p._pre (); + p._characters ("01"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/boolean/makefile b/tests/cxx/parser/validation/built-in/boolean/makefile new file mode 100644 index 0000000..bc753b2 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/boolean/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/boolean/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/byte/driver.cxx b/tests/cxx/parser/validation/built-in/byte/driver.cxx new file mode 100644 index 0000000..a7fa905 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/byte/driver.cxx @@ -0,0 +1,258 @@ +// file : tests/cxx/parser/validation/built-in/byte/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in byte and unsigned byte types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t +123 \n "); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0000000000000000123"); + p._post (); + assert (p.post_byte () == 123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000000000000000123"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("\t \n"); + p._characters (" -"); + p._characters ("00000"); + p._characters ("001"); + p._characters ("23 \n\t"); + p._post (); + assert (p.post_byte () == -123); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-128"); + p._post (); + assert (p.post_byte () == -128); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("127"); + p._post (); + assert (p.post_byte () == 127); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+123"); + p._post (); + assert (p.post_unsigned_byte () == 123); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_byte () == 0); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("255"); + p._post (); + assert (p.post_unsigned_byte () == 255); + } + + // Bad + // + { + byte_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n \t "); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("+"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("++01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-01"); + p._characters (" "); + p._characters ("23 "); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + // Ranges + // + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("-129"); + assert (test_post_fail (p)); + } + + { + byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("128"); + assert (test_post_fail (p)); + } + + { + unsigned_byte_pimpl p; + p.pre (); + p._pre (); + p._characters ("256"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/byte/makefile b/tests/cxx/parser/validation/built-in/byte/makefile new file mode 100644 index 0000000..7e3655b --- /dev/null +++ b/tests/cxx/parser/validation/built-in/byte/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/byte/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/date-time/driver.cxx b/tests/cxx/parser/validation/built-in/date-time/driver.cxx new file mode 100644 index 0000000..16d876d --- /dev/null +++ b/tests/cxx/parser/validation/built-in/date-time/driver.cxx @@ -0,0 +1,1535 @@ +// file : tests/cxx/parser/validation/built-in/date-time/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in date and time types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::gday gday; + typedef xsd::cxx::parser::gmonth gmonth; + typedef xsd::cxx::parser::gyear gyear; + typedef xsd::cxx::parser::gmonth_day gmonth_day; + typedef xsd::cxx::parser::gyear_month gyear_month; + typedef xsd::cxx::parser::date date; + typedef xsd::cxx::parser::time time; + typedef xsd::cxx::parser::date_time date_time; + typedef xsd::cxx::parser::duration duration; + + // Good. + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("---1"); + p._characters ("2+12:00"); + p._post (); + assert (p.post_gday () == gday (12, 12, 00)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---01"); + p._post (); + assert (p.post_gday () == gday (1)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---31"); + p._post (); + assert (p.post_gday () == gday (31)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15Z"); + p._post (); + assert (p.post_gday () == gday (15, 0, 0)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---15-14:00"); + p._post (); + assert (p.post_gday () == gday (15, -14, 0)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("--1"); + p._characters ("0+12:00"); + p._post (); + assert (p.post_gmonth () == gmonth (10, 12, 0)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01"); + p._post (); + assert (p.post_gmonth () == gmonth (1)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12Z"); + p._post (); + assert (p.post_gmonth () == gmonth (12, 0, 0)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("20"); + p._characters ("07+12:00"); + p._post (); + assert (p.post_gyear () == gyear (2007, 12, 00)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("0001"); + p._post (); + assert (p.post_gyear () == gyear (1)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20000Z"); + p._post (); + assert (p.post_gyear () == gyear (-20000, 0, 0)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("--1"); + p._characters ("0-28+12:00 "); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (10, 28, 12, 00)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-31"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (12, 31)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--01-01Z"); + p._post (); + assert (p.post_gmonth_day () == gmonth_day (1, 1, 0, 0)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12+12:00 "); + p._post (); + assert (p.post_gyear_month () == gyear_month (2007, 12, 12, 00)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-2007, 10)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-10Z"); + p._post (); + assert (p.post_gyear_month () == gyear_month (20007, 10, 0, 0)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01"); + p._post (); + assert (p.post_gyear_month () == gyear_month (-20007, 1)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12-26+12:00 "); + p._post (); + assert (p.post_date () == date (2007, 12, 26, 12, 0)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15"); + p._post (); + assert (p.post_date () == date (-2007, 10, 15)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-12-31Z"); + p._post (); + assert (p.post_date () == date (20007, 12, 31, 0, 0)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01"); + p._post (); + assert (p.post_date () == date (-20007, 1, 1)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("12:"); + p._characters ("46:23.456+12:00 "); + p._post (); + assert (p.post_time () == time (12, 46, 23.456, 12, 0)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("12:13:14Z"); + p._post (); + assert (p.post_time () == time (12, 13, 14.0, 0, 0)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("200"); + p._characters ("7-12-26T12:13:14.123+12:00 "); + p._post (); + assert (p.post_date_time () == + date_time (2007, 12, 26, 12, 13, 14.123, 12, 0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007-10-15T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-2007, 10, 15, 12, 13, 14.0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("20007-12-31T12:13:14Z"); + p._post (); + assert (p.post_date_time () == + date_time (20007, 12, 31, 12, 13, 14.0, 0, 0)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-20007-01-01T12:13:14"); + p._post (); + assert (p.post_date_time () == date_time (-20007, 1, 1, 12, 13, 14.0)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters (" \t\n "); + p._characters ("-P200"); + p._characters ("7Y13M32DT25H61M61.123S "); + p._post (); + assert (p.post_duration () == + duration (true, 2007, 13, 32, 25, 61, 61.123)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Y"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 1, 0, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1D"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 1, 0, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 1, 0, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1M"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 1, 0.0)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1.1S"); + p._post (); + assert (p.post_duration () == duration (false, 0, 0, 0, 0, 0, 1.1)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT1S"); + p._post (); + assert (p.post_duration () == duration (false, 1, 0, 0, 0, 0, 1.0)); + } + + // Bad + // + + // gday & time zone parsing + // + { + gday_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---32"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---2X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12asd"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12X"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---1212:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+2:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+1200"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+15:00"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+12:60"); + assert (test_post_fail (p)); + } + + { + gday_pimpl p; + p.pre (); + p._pre (); + p._characters ("---12+14:01"); + assert (test_post_fail (p)); + } + + // gmonth + // + { + gmonth_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X"); + assert (test_post_fail (p)); + } + + { + gmonth_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear + // + { + gyear_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0000"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7"); + assert (test_post_fail (p)); + } + + { + gyear_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007+12:3o"); + assert (test_post_fail (p)); + } + + // gmonth_day + // + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1212"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12?12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--00-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-00"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--13-23"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-32"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--1X-12"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--12-2X"); + assert (test_post_fail (p)); + } + + { + gmonth_day_pimpl p; + p.pre (); + p._pre (); + p._characters ("--11-11+12:3o"); + assert (test_post_fail (p)); + } + + // gyear_month + // + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?12"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X"); + assert (test_post_fail (p)); + } + + { + gyear_month_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01+12:3o"); + assert (test_post_fail (p)); + } + + // date + // + { + date_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2X"); + assert (test_post_fail (p)); + } + + { + date_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01+12:3o"); + assert (test_post_fail (p)); + } + + // time + // + { + time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2X:01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23?01:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:0:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:60:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:4X:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10?12"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:0"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:01."); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:60"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:10:2X"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:01:00"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("24:00:01"); + assert (test_post_fail (p)); + } + + { + time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + // date_time + // + { + date_time_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("-207-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("0000-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("20X7-01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007?01-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-0-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-00-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-13-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-1X-01T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10?12T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-0T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-00T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-32T12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-10-2XT12:13:14"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T1:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T2X:01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23?01:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:0:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:60:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:4X:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10?12"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:0"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:01."); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:60"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T23:10:2X"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:01:00"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T24:00:01"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("23:01:01+12:3o"); + assert (test_post_fail (p)); + } + + { + date_time_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007-01-01T12:13:14+12:3o"); + assert (test_post_fail (p)); + } + + // duration + // + { + duration_pimpl p; + p.pre (); + p._pre (); + // p._characters (""); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-2007Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P-1D"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1M"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT-1.1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1H1M1S"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1M1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1S1H"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("PT1H1Y"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1Ygarbage"); + assert (test_post_fail (p)); + } + + { + duration_pimpl p; + p.pre (); + p._pre (); + p._characters ("P1YT"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/date-time/makefile b/tests/cxx/parser/validation/built-in/date-time/makefile new file mode 100644 index 0000000..1d1dd20 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/date-time/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/date-time/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/float/driver.cxx b/tests/cxx/parser/validation/built-in/float/driver.cxx new file mode 100644 index 0000000..1b8454c --- /dev/null +++ b/tests/cxx/parser/validation/built-in/float/driver.cxx @@ -0,0 +1,287 @@ +// file : tests/cxx/parser/validation/built-in/float/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in float, double, and decimal types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456 "); + p._post (); + assert (p.post_float () == 123.456F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.345E2"); + p._post (); + assert (p.post_float () == -12.345E2F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_float () == 0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_float () == -0.0F); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_float ())); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_float ())); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_double () == 123.456789); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-12.3456789E2"); + p._post (); + assert (p.post_double () == -12.3456789E2); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_double () == 0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_double () == -0.0); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + p._post (); + assert (isinf (p.post_double ())); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + p._post (); + assert (isnan (p.post_double ())); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters (" 0000123.456789 "); + p._post (); + assert (p.post_decimal () == 123.456789); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123.45678912345"); + p._post (); + assert (p.post_decimal () == -123.45678912345); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_decimal () == 0.0); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_decimal () == -0.0); + } + + + // Bad + // + + // float + // + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + float_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // double + // + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + double_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 E2"); + assert (test_post_fail (p)); + } + + // decimal + // + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("+INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("-INF"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("NaN"); + assert (test_post_fail (p)); + } + + { + decimal_pimpl p; + p.pre (); + p._pre (); + p._characters ("1.45 2"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/float/makefile b/tests/cxx/parser/validation/built-in/float/makefile new file mode 100644 index 0000000..b6c478d --- /dev/null +++ b/tests/cxx/parser/validation/built-in/float/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/float/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/int/driver.cxx b/tests/cxx/parser/validation/built-in/int/driver.cxx new file mode 100644 index 0000000..682eea9 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/int/driver.cxx @@ -0,0 +1,118 @@ +// file : tests/cxx/parser/validation/built-in/int/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in int and unsigned int types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483648"); + p._post (); + assert (p.post_int () == -2147483648); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_int () == 0); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483647"); + p._post (); + assert (p.post_int () == 2147483647); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_int () == 0); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967295"); + p._post (); + assert (p.post_unsigned_int () == 4294967295); + } + + // Bad + // + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("-2147483649"); + assert (test_post_fail (p)); + } + + { + int_pimpl p; + p.pre (); + p._pre (); + p._characters ("2147483648"); + assert (test_post_fail (p)); + } + + { + unsigned_int_pimpl p; + p.pre (); + p._pre (); + p._characters ("4294967296"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/int/makefile b/tests/cxx/parser/validation/built-in/int/makefile new file mode 100644 index 0000000..e70782a --- /dev/null +++ b/tests/cxx/parser/validation/built-in/int/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/int/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/integer/driver.cxx b/tests/cxx/parser/validation/built-in/integer/driver.cxx new file mode 100644 index 0000000..6dd04d2 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/integer/driver.cxx @@ -0,0 +1,305 @@ +// file : tests/cxx/parser/validation/built-in/int/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in integer & friends types validation. +// +#include + +#include +#include +#include + +#include +#include + +using namespace std; +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + + std::string min; + std::string max; + std::string umax; + + { + ostringstream ostr; + ostr << LLONG_MIN; + min = ostr.str (); + } + + { + ostringstream ostr; + ostr << LLONG_MAX; + max = ostr.str (); + } + + { + ostringstream ostr; + ostr << ULLONG_MAX; + umax = ostr.str (); + } + + // integer + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MIN); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_integer () == 0); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (max.c_str ()); + p._post (); + assert (p.post_integer () == LLONG_MAX); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_negative_integer () == LLONG_MIN); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + p._post (); + assert (p.post_negative_integer () == -1); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (min.c_str ()); + p._post (); + assert (p.post_non_positive_integer () == LLONG_MIN); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + p._post (); + assert (p.post_non_positive_integer () == 0); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + p._post (); + assert (p.post_positive_integer () == 1); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_positive_integer () == ULLONG_MAX); + } + + // non_negative_integer + // + /* + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + */ + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_non_negative_integer () == 0); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (umax.c_str ()); + p._post (); + assert (p.post_non_negative_integer () == ULLONG_MAX); + } + + + // Bad + // + + std::string past_min (min); + std::string past_max (max); + std::string past_umax (umax); + + assert (*past_min.rbegin () != '9'); + assert (*past_max.rbegin () != '9'); + assert (*past_umax.rbegin () != '9'); + + (*past_min.rbegin ())++; + (*past_max.rbegin ())++; + (*past_umax.rbegin ())++; + + // integer + // + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_max.c_str ()); + assert (test_post_fail (p)); + } + + // negative_integer + // + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-0"); + assert (test_post_fail (p)); + } + + { + negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // non_positive_integer + // + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_min.c_str ()); + assert (test_post_fail (p)); + } + + { + non_positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("1"); + assert (test_post_fail (p)); + } + + // positive_integer + // + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("+0"); + assert (test_post_fail (p)); + } + + { + positive_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } + + // non_negative_integer + // + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1"); + assert (test_post_fail (p)); + } + + { + non_negative_integer_pimpl p; + p.pre (); + p._pre (); + p._characters (past_umax.c_str ()); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/integer/makefile b/tests/cxx/parser/validation/built-in/integer/makefile new file mode 100644 index 0000000..8b0d68c --- /dev/null +++ b/tests/cxx/parser/validation/built-in/integer/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/integer/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/long/driver.cxx b/tests/cxx/parser/validation/built-in/long/driver.cxx new file mode 100644 index 0000000..462c7e7 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/long/driver.cxx @@ -0,0 +1,118 @@ +// file : tests/cxx/parser/validation/built-in/long/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in long and unsigned long types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775808"); + p._post (); + assert (p.post_long () == (-9223372036854775807LL - 1)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_long () == 0); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775807"); + p._post (); + assert (p.post_long () == 9223372036854775807LL); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_long () == 0); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551615"); + p._post (); + assert (p.post_unsigned_long () == 18446744073709551615ULL); + } + + // Bad + // + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-123"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("-9223372036854775809"); + assert (test_post_fail (p)); + } + + { + long_pimpl p; + p.pre (); + p._pre (); + p._characters ("9223372036854775808"); + assert (test_post_fail (p)); + } + + { + unsigned_long_pimpl p; + p.pre (); + p._pre (); + p._characters ("18446744073709551616"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/long/makefile b/tests/cxx/parser/validation/built-in/long/makefile new file mode 100644 index 0000000..201a984 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/long/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/long/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/makefile b/tests/cxx/parser/validation/built-in/makefile new file mode 100644 index 0000000..e0728b0 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/makefile @@ -0,0 +1,21 @@ +# file : tests/cxx/parser/validation/built-in/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make + +tests := any-type binary boolean byte date-time float int integer long \ +qname short string uri + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/parser/validation/built-in/qname/driver.cxx b/tests/cxx/parser/validation/built-in/qname/driver.cxx new file mode 100644 index 0000000..3a2f88d --- /dev/null +++ b/tests/cxx/parser/validation/built-in/qname/driver.cxx @@ -0,0 +1,107 @@ +// file : tests/cxx/parser/validation/built-in/qname/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in QName type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +bool +test_post_fail (qname_pimpl& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::qname qname; + + // Good. + // + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (" xsi"); + p._characters (":"); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("xsi", "schemaLocation")); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("schemaLocation"); + p._post (); + assert (p.post_qname () == qname ("schemaLocation")); + } + + + // Bad + // + { + qname_pimpl p; + p.pre (); + p._pre (); + //p._characters (""); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters (":schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("x?i:schemaLocation"); + assert (test_post_fail (p)); + } + + { + qname_pimpl p; + p.pre (); + p._pre (); + p._characters ("xsi:schema Location"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/qname/makefile b/tests/cxx/parser/validation/built-in/qname/makefile new file mode 100644 index 0000000..496af30 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/qname/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/qname/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/short/driver.cxx b/tests/cxx/parser/validation/built-in/short/driver.cxx new file mode 100644 index 0000000..51eaee3 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/short/driver.cxx @@ -0,0 +1,118 @@ +// file : tests/cxx/parser/validation/built-in/short/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in short and unsigned short types validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post (); + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + // Good. + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32768"); + p._post (); + assert (p.post_short () == -32768); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_short () == 0); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32767"); + p._post (); + assert (p.post_short () == 32767); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("0"); + p._post (); + assert (p.post_unsigned_short () == 0); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65535"); + p._post (); + assert (p.post_unsigned_short () == 65535); + } + + // Bad + // + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-1234"); + assert (test_post_fail (p)); + } + + + // Ranges + // + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("-32769"); + assert (test_post_fail (p)); + } + + { + short_pimpl p; + p.pre (); + p._pre (); + p._characters ("32768"); + assert (test_post_fail (p)); + } + + { + unsigned_short_pimpl p; + p.pre (); + p._pre (); + p._characters ("65536"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/short/makefile b/tests/cxx/parser/validation/built-in/short/makefile new file mode 100644 index 0000000..c3916dc --- /dev/null +++ b/tests/cxx/parser/validation/built-in/short/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/short/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/string/driver.cxx b/tests/cxx/parser/validation/built-in/string/driver.cxx new file mode 100644 index 0000000..a9b552c --- /dev/null +++ b/tests/cxx/parser/validation/built-in/string/driver.cxx @@ -0,0 +1,514 @@ +// file : tests/cxx/parser/validation/built-in/string/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in string & friends types validation. +// +#include +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +template +bool +test_post_fail (T& p) +{ + try + { + p._post_impl (); // List implementation needs this to be post_impl. + } + catch (invalid_value const&) + { + return true; + } + + return false; +} + +int +main () +{ + typedef xsd::cxx::parser::string_sequence strings; + + // Good. + // + + // string + // + { + string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa "); + p._characters ("bbb"); + p._characters (" "); + p._post (); + assert (p.post_string () == " \n\t aaa bbb "); + } + + // normalized_string + // + { + normalized_string_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb"); + p._characters (" "); + p._post (); + assert (p.post_normalized_string () == " aaa bbb "); + } + + // token + // + { + token_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" aaa \n\t "); + p._characters (" bbb \n\t"); + p._characters (" "); + p._post (); + assert (p.post_token () == "aaa bbb"); + } + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a:b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "a:b-c_d123"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" _12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == "_12"); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" :12 "); + p._characters (" "); + p._post (); + assert (p.post_name () == ":12"); + } + + // nmtoken + // + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123a:b-c_d123 "); + p._characters (" \n\t"); + p._characters (" "); + p._post (); + assert (p.post_nmtoken () == "123a:b-c_d123"); + } + + // nmtokens + // + { + strings s; + s.push_back ("123"); + s.push_back ("abc"); + + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" 123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_nmtokens () == s); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_ncname () == "a.b-c_d123"); + } + + // id + // + { + id_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_id () == "a.b-c_d123"); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a.b-c_d123 "); + p._characters (" "); + p._post (); + assert (p.post_idref () == "a.b-c_d123"); + } + + // idrefs + // + { + strings s; + s.push_back ("a123"); + s.push_back ("abc"); + + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" \n\t"); + p._characters (" a123 "); + p._characters (" \n\t abc "); + p._characters (" "); + p._post (); + assert (p.post_idrefs () == s); + } + + // language + // + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" x "); + p._post (); + assert (p.post_language () == "x"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en "); + p._post (); + assert (p.post_language () == "en"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters (" en"); + p._characters ("-us "); + p._post (); + assert (p.post_language () == "en-us"); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("one-two-three-four44-seven77-eight888"); + p._post (); + assert (p.post_language () == "one-two-three-four44-seven77-eight888"); + } + + + // Bad + // + + // name + // + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + name_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + nmtoken_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + nmtokens_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a,b"); + assert (test_post_fail (p)); + } + + // ncname + // + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (""); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (".a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("-a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters (":a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("1:a"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a,b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + { + ncname_pimpl p; + p.pre (); + p._pre (); + p._characters ("a p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idref + // + { + idref_pimpl p; + p.pre (); + p._pre (); + p._characters ("a b"); + assert (test_post_fail (p)); + } + + // idrefs + // + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._characters (" \t\n "); + assert (test_post_fail (p)); + } + + { + idrefs_pimpl p; + p.pre (); + p._pre (); + p._characters ("ab a p; + p.pre (); + p._pre (); + p._characters (" "); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("a1"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en+us"); + assert (test_post_fail (p)); + } + + { + language_pimpl p; + p.pre (); + p._pre (); + p._characters ("en-nine99999"); + assert (test_post_fail (p)); + } +} diff --git a/tests/cxx/parser/validation/built-in/string/makefile b/tests/cxx/parser/validation/built-in/string/makefile new file mode 100644 index 0000000..7ac9c5a --- /dev/null +++ b/tests/cxx/parser/validation/built-in/string/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/string/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/built-in/uri/driver.cxx b/tests/cxx/parser/validation/built-in/uri/driver.cxx new file mode 100644 index 0000000..959e1c1 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/uri/driver.cxx @@ -0,0 +1,55 @@ +// file : tests/cxx/parser/validation/built-in/uri/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the built-in anyURI type validation. +// +#include + +#include +#include + +using namespace xsd::cxx::parser::validating; + +int +main () +{ + // Good. + // + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters (" "); + p._post (); + assert (p.post_uri () == ""); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("relative"); + p._post (); + assert (p.post_uri () == "relative"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("#id"); + p._post (); + assert (p.post_uri () == "#id"); + } + + { + uri_pimpl p; + p.pre (); + p._pre (); + p._characters ("http://www.example.com/foo#bar"); + p._post (); + assert (p.post_uri () == "http://www.example.com/foo#bar"); + } +} diff --git a/tests/cxx/parser/validation/built-in/uri/makefile b/tests/cxx/parser/validation/built-in/uri/makefile new file mode 100644 index 0000000..b6341b0 --- /dev/null +++ b/tests/cxx/parser/validation/built-in/uri/makefile @@ -0,0 +1,60 @@ +# file : tests/cxx/parser/validation/built-in/uri/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../../build/bootstrap.make + +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.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) + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) + + +# 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) diff --git a/tests/cxx/parser/validation/choice/driver.cxx b/tests/cxx/parser/validation/choice/driver.cxx new file mode 100644 index 0000000..234bfc2 --- /dev/null +++ b/tests/cxx/parser/validation/choice/driver.cxx @@ -0,0 +1,128 @@ +// file : tests/cxx/parser/validation/choice/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the choice compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct choice_pimpl: choice_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + d (string const& v) + { + cout << " d = " << v << endl; + } + + virtual void + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + cout << " any: " << ns << "#" << name << endl + << " {" << endl; + } + + virtual void + _any_characters (ro_string const& v) + { + cout << " chars = " << v << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const&) + { + cout << " }" << endl; + } + + virtual void + post_choice () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + choice_pimpl choice_p; + type_pimpl type_p; + + choice_p.parsers (string_p, string_p, string_p, string_p); + type_p.parsers (choice_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/choice/makefile b/tests/cxx/parser/validation/choice/makefile new file mode 100644 index 0000000..2e957d6 --- /dev/null +++ b/tests/cxx/parser/validation/choice/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/choice/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 001 002 003 004 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/choice/test-000.std b/tests/cxx/parser/validation/choice/test-000.std new file mode 100644 index 0000000..856b7f5 --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-000.std @@ -0,0 +1,22 @@ +{ + a = a + b = b +} + +{ + c = c + d = d + any: other#any + { + chars = any + } + a = a +} + +{ + c = c + d = d + d = d + a = a +} + diff --git a/tests/cxx/parser/validation/choice/test-000.xml b/tests/cxx/parser/validation/choice/test-000.xml new file mode 100644 index 0000000..39b9614 --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-000.xml @@ -0,0 +1,30 @@ + + + + a + + b + + + + c + d + + any + + a + + + + c + d + + d + + a + + + diff --git a/tests/cxx/parser/validation/choice/test-001.std b/tests/cxx/parser/validation/choice/test-001.std new file mode 100644 index 0000000..8a78666 --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-001.std @@ -0,0 +1,4 @@ +{ + :8:12 error: expected element 'a' +} + diff --git a/tests/cxx/parser/validation/choice/test-001.xml b/tests/cxx/parser/validation/choice/test-001.xml new file mode 100644 index 0000000..c509e0d --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-001.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/tests/cxx/parser/validation/choice/test-002.std b/tests/cxx/parser/validation/choice/test-002.std new file mode 100644 index 0000000..1dc1a3a --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-002.std @@ -0,0 +1,11 @@ +{ + c = c + d = d + any: other#any + { + chars = any + } + a = a + :14:8 error: unexpected element 'b' +} + diff --git a/tests/cxx/parser/validation/choice/test-002.xml b/tests/cxx/parser/validation/choice/test-002.xml new file mode 100644 index 0000000..3b7e663 --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-002.xml @@ -0,0 +1,17 @@ + + + + + c + d + + any + + a + b + + + diff --git a/tests/cxx/parser/validation/choice/test-003.std b/tests/cxx/parser/validation/choice/test-003.std new file mode 100644 index 0000000..29d5e44 --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-003.std @@ -0,0 +1,5 @@ +{ + c = c + :9:12 error: expected element 'd' +} + diff --git a/tests/cxx/parser/validation/choice/test-003.xml b/tests/cxx/parser/validation/choice/test-003.xml new file mode 100644 index 0000000..ba15c7e --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-003.xml @@ -0,0 +1,11 @@ + + + + + c + + + diff --git a/tests/cxx/parser/validation/choice/test-004.std b/tests/cxx/parser/validation/choice/test-004.std new file mode 100644 index 0000000..4a7530b --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-004.std @@ -0,0 +1,4 @@ +{ + :8:8 error: expected element 'a' instead of 'x' +} + diff --git a/tests/cxx/parser/validation/choice/test-004.xml b/tests/cxx/parser/validation/choice/test-004.xml new file mode 100644 index 0000000..f6960dd --- /dev/null +++ b/tests/cxx/parser/validation/choice/test-004.xml @@ -0,0 +1,11 @@ + + + + + x + + + diff --git a/tests/cxx/parser/validation/choice/test.xsd b/tests/cxx/parser/validation/choice/test.xsd new file mode 100644 index 0000000..8132bbb --- /dev/null +++ b/tests/cxx/parser/validation/choice/test.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/makefile b/tests/cxx/parser/validation/makefile new file mode 100644 index 0000000..9000e4c --- /dev/null +++ b/tests/cxx/parser/validation/makefile @@ -0,0 +1,22 @@ +# file : tests/cxx/parser/validation/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + + +tests := all any attribute built-in choice restriction sequence + + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/parser/validation/restriction/driver.cxx b/tests/cxx/parser/validation/restriction/driver.cxx new file mode 100644 index 0000000..34db4d2 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/driver.cxx @@ -0,0 +1,109 @@ +// file : tests/cxx/parser/validation/restriction/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the restriction compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_a_pimpl: base_a_pskel +{ +}; + +struct restriction_a_pimpl: restriction_a_pskel +{ +}; + +struct extension_b_pimpl: extension_b_pskel +{ +}; + +struct restriction_b_pimpl: restriction_b_pskel +{ +}; + +struct type_b_pimpl: type_b_pskel +{ +}; + +struct type_r_pimpl: type_r_pskel +{ +}; + + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + base_a_pimpl base_a_p; + restriction_a_pimpl restriction_a_p; + extension_b_pimpl extension_b_p; + restriction_b_pimpl restriction_b_p; + type_b_pimpl type_b_p; + type_r_pimpl type_r_p; + + base_a_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + + restriction_a_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + + extension_b_p.parsers (string_p, string_p, string_p, + string_p, string_p); + + restriction_b_p.parsers (string_p, string_p, string_p, + string_p, string_p); + + type_b_p.parsers (base_a_p, extension_b_p); + type_r_p.parsers (restriction_a_p, restriction_b_p); + + xml_schema::document doc_b_p (type_b_p, "test", "root"); + xml_schema::document doc_r_p (type_r_p, "test", "root"); + + { + ifstream ifs (argv[1]); + type_b_p.pre (); + doc_b_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_b_p.post_type_b (); + } + + try + { + ifstream ifs (argv[1]); + type_r_p.pre (); + doc_r_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_r_p.post_type_r (); + } + catch (xml_schema::exception const& e) + { + cout << e << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/restriction/makefile b/tests/cxx/parser/validation/restriction/makefile new file mode 100644 index 0000000..bb78c5e --- /dev/null +++ b/tests/cxx/parser/validation/restriction/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/restriction/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 001 002 003 004 005 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/restriction/test-000.std b/tests/cxx/parser/validation/restriction/test-000.std new file mode 100644 index 0000000..e69de29 diff --git a/tests/cxx/parser/validation/restriction/test-000.xml b/tests/cxx/parser/validation/restriction/test-000.xml new file mode 100644 index 0000000..21402b4 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-000.xml @@ -0,0 +1,31 @@ + + + + a + b + c + + + + a + b + c + + + + a + b + + + + a + c + + + + a + + + diff --git a/tests/cxx/parser/validation/restriction/test-001.std b/tests/cxx/parser/validation/restriction/test-001.std new file mode 100644 index 0000000..5077837 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-001.std @@ -0,0 +1 @@ +:7:8 error: expected element 'a' instead of 'b' diff --git a/tests/cxx/parser/validation/restriction/test-001.xml b/tests/cxx/parser/validation/restriction/test-001.xml new file mode 100644 index 0000000..4015302 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-001.xml @@ -0,0 +1,11 @@ + + + + + b + c + + + diff --git a/tests/cxx/parser/validation/restriction/test-002.std b/tests/cxx/parser/validation/restriction/test-002.std new file mode 100644 index 0000000..f12c342 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-002.std @@ -0,0 +1 @@ +:10:19 error: expected attribute 'z' diff --git a/tests/cxx/parser/validation/restriction/test-002.xml b/tests/cxx/parser/validation/restriction/test-002.xml new file mode 100644 index 0000000..eb7684c --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-002.xml @@ -0,0 +1,12 @@ + + + + + a + b + c + + + diff --git a/tests/cxx/parser/validation/restriction/test-003.std b/tests/cxx/parser/validation/restriction/test-003.std new file mode 100644 index 0000000..0c65175 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-003.std @@ -0,0 +1 @@ +:11:8 error: unexpected element 'a' diff --git a/tests/cxx/parser/validation/restriction/test-003.xml b/tests/cxx/parser/validation/restriction/test-003.xml new file mode 100644 index 0000000..49f18c7 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-003.xml @@ -0,0 +1,16 @@ + + + + + a + b + c + + a + b + c + + + diff --git a/tests/cxx/parser/validation/restriction/test-004.std b/tests/cxx/parser/validation/restriction/test-004.std new file mode 100644 index 0000000..5077837 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-004.std @@ -0,0 +1 @@ +:7:8 error: expected element 'a' instead of 'b' diff --git a/tests/cxx/parser/validation/restriction/test-004.xml b/tests/cxx/parser/validation/restriction/test-004.xml new file mode 100644 index 0000000..115cd38 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-004.xml @@ -0,0 +1,10 @@ + + + + + b + + + diff --git a/tests/cxx/parser/validation/restriction/test-005.std b/tests/cxx/parser/validation/restriction/test-005.std new file mode 100644 index 0000000..e92de14 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-005.std @@ -0,0 +1 @@ +:9:19 error: expected attribute 'y' diff --git a/tests/cxx/parser/validation/restriction/test-005.xml b/tests/cxx/parser/validation/restriction/test-005.xml new file mode 100644 index 0000000..e9ab7d9 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test-005.xml @@ -0,0 +1,11 @@ + + + + + a + b + + + diff --git a/tests/cxx/parser/validation/restriction/test.xsd b/tests/cxx/parser/validation/restriction/test.xsd new file mode 100644 index 0000000..158ded5 --- /dev/null +++ b/tests/cxx/parser/validation/restriction/test.xsd @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/parser/validation/sequence/driver.cxx b/tests/cxx/parser/validation/sequence/driver.cxx new file mode 100644 index 0000000..a1e1101 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/driver.cxx @@ -0,0 +1,141 @@ +// file : tests/cxx/parser/validation/sequence/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the sequence compositor validation. +// + +#include +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; +using xml_schema::ro_string; + +struct sequence_pimpl: sequence_pskel +{ + virtual void + pre () + { + cout << "{" << endl; + } + + virtual void + a (string const& v) + { + cout << " a = " << v << endl; + } + + virtual void + b (string const& v) + { + cout << " b = " << v << endl; + } + + virtual void + c (string const& v) + { + cout << " c = " << v << endl; + } + + virtual void + d (string const& v) + { + cout << " d = " << v << endl; + } + + virtual void + e (string const& v) + { + cout << " e = " << v << endl; + } + + virtual void + f (string const& v) + { + cout << " f = " << v << endl; + } + + virtual void + _start_any_element (ro_string const& ns, + ro_string const& name, + ro_string const*) + { + cout << " any: " << ns << "#" << name << endl + << " {" << endl; + } + + virtual void + _any_characters (ro_string const& v) + { + cout << " chars = " << v << endl; + } + + virtual void + _end_any_element (ro_string const&, ro_string const&) + { + cout << " }" << endl; + } + + virtual void + post_sequence () + { + cout << "}" << endl + << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + sequence_pimpl sequence_p; + type_pimpl type_p; + + sequence_p.parsers (string_p, string_p, string_p, + string_p, string_p, string_p); + type_p.parsers (sequence_p); + + xml_schema::document doc_p (type_p, "test", "root"); + + try + { + ifstream ifs (argv[1]); + type_p.pre (); + doc_p.parse (ifs, argv[1], "", xml_schema::flags::dont_validate); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cout << " " << e << endl + << "}" << endl + << endl; + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/tests/cxx/parser/validation/sequence/makefile b/tests/cxx/parser/validation/sequence/makefile new file mode 100644 index 0000000..e06b3a0 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/makefile @@ -0,0 +1,85 @@ +# file : tests/cxx/parser/validation/sequence/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +tests := 000 001 002 003 004 005 006 + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.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) + +skel := $(out_base)/$(xsd:.xsd=-pskel.hxx) \ + $(out_base)/$(xsd:.xsd=-pskel.ixx) \ + $(out_base)/$(xsd:.xsd=-pskel.cxx) + +$(skel): xsd := $(out_root)/xsd/xsd +$(skel): xsd_options := --generate-validation +$(skel): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +.PHONY: $(test) +$(test): $(test_targets) + + +$(test_targets): driver := $(driver) + +.PHONY: $(out_base)/.test-% +$(out_base)/.test-%: $(driver) $(src_base)/test.xsd $(src_base)/test-%.xml $(src_base)/test-%.std + $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=-pskel.cxx.xsd.clean)) + + +# 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/parser/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/parser/validation/sequence/test-000.std b/tests/cxx/parser/validation/sequence/test-000.std new file mode 100644 index 0000000..8a44762 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-000.std @@ -0,0 +1,56 @@ +{ + c = c + d = d + any: test#any + { + chars = aaa + any: #a + { + chars = bbb + } + chars = ccc + } + f = f + e = e +} + +{ + a = a + b = b + c = c + d = d + d = d + d = d + any: other#any + { + chars = any + } + f = f + e = e + e = e +} + +{ + a = a + b = b + c = c + d = d + d = d + d = d + any: other#any + { + chars = any + } + f = f + e = e + e = e + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e +} + diff --git a/tests/cxx/parser/validation/sequence/test-000.xml b/tests/cxx/parser/validation/sequence/test-000.xml new file mode 100644 index 0000000..9bcbd7e --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-000.xml @@ -0,0 +1,46 @@ + + + + c + d + aaabbbccc + f + e + + + + a + b + c + d + d + d + any + f + e + e + + + + a + b + c + d + d + d + any + f + e + e + + c + d + any + f + e + + + diff --git a/tests/cxx/parser/validation/sequence/test-001.std b/tests/cxx/parser/validation/sequence/test-001.std new file mode 100644 index 0000000..20dea34 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-001.std @@ -0,0 +1,4 @@ +{ + :8:14 error: expected element 'a' +} + diff --git a/tests/cxx/parser/validation/sequence/test-001.xml b/tests/cxx/parser/validation/sequence/test-001.xml new file mode 100644 index 0000000..67d33ce --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-001.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/tests/cxx/parser/validation/sequence/test-002.std b/tests/cxx/parser/validation/sequence/test-002.std new file mode 100644 index 0000000..61343e7 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-002.std @@ -0,0 +1,20 @@ +{ + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + :20:8 error: unexpected element 'c' +} + diff --git a/tests/cxx/parser/validation/sequence/test-002.xml b/tests/cxx/parser/validation/sequence/test-002.xml new file mode 100644 index 0000000..be25fcf --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-002.xml @@ -0,0 +1,27 @@ + + + + + c + d + any + f + e + + c + d + any + f + e + + c + d + any + f + e + + + diff --git a/tests/cxx/parser/validation/sequence/test-003.std b/tests/cxx/parser/validation/sequence/test-003.std new file mode 100644 index 0000000..c4e1e46 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-003.std @@ -0,0 +1,5 @@ +{ + a = a + :9:8 error: expected element 'b' instead of 'a' +} + diff --git a/tests/cxx/parser/validation/sequence/test-003.xml b/tests/cxx/parser/validation/sequence/test-003.xml new file mode 100644 index 0000000..af7d21d --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-003.xml @@ -0,0 +1,17 @@ + + + + + a + a + c + d + any + f + e + + + diff --git a/tests/cxx/parser/validation/sequence/test-004.std b/tests/cxx/parser/validation/sequence/test-004.std new file mode 100644 index 0000000..f4c1d4d --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-004.std @@ -0,0 +1,4 @@ +{ + :8:8 error: expected element 'a' instead of 'd' +} + diff --git a/tests/cxx/parser/validation/sequence/test-004.xml b/tests/cxx/parser/validation/sequence/test-004.xml new file mode 100644 index 0000000..a58b6d4 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-004.xml @@ -0,0 +1,14 @@ + + + + + d + any + f + e + + + diff --git a/tests/cxx/parser/validation/sequence/test-005.std b/tests/cxx/parser/validation/sequence/test-005.std new file mode 100644 index 0000000..9fa7904 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-005.std @@ -0,0 +1,6 @@ +{ + c = c + d = d + :10:13 error: expected element '##targetNamespace#*' instead of 'other1#any' +} + diff --git a/tests/cxx/parser/validation/sequence/test-005.xml b/tests/cxx/parser/validation/sequence/test-005.xml new file mode 100644 index 0000000..e3dd03d --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-005.xml @@ -0,0 +1,15 @@ + + + + + c + d + any + f + e + + + diff --git a/tests/cxx/parser/validation/sequence/test-006.std b/tests/cxx/parser/validation/sequence/test-006.std new file mode 100644 index 0000000..eb79f47 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-006.std @@ -0,0 +1,13 @@ +{ + c = c + d = d + any: test#any + { + chars = any + } + f = f + e = e + e = e + :14:8 error: unexpected element 'e' +} + diff --git a/tests/cxx/parser/validation/sequence/test-006.xml b/tests/cxx/parser/validation/sequence/test-006.xml new file mode 100644 index 0000000..e1ecd69 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test-006.xml @@ -0,0 +1,17 @@ + + + + + c + d + any + f + e + e + e + + + diff --git a/tests/cxx/parser/validation/sequence/test.xsd b/tests/cxx/parser/validation/sequence/test.xsd new file mode 100644 index 0000000..8753f54 --- /dev/null +++ b/tests/cxx/parser/validation/sequence/test.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/binary/cdr/driver.cxx b/tests/cxx/tree/binary/cdr/driver.cxx new file mode 100644 index 0000000..40cb799 --- /dev/null +++ b/tests/cxx/tree/binary/cdr/driver.cxx @@ -0,0 +1,137 @@ +// file : tests/cxx/tree/binary/cdr/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test non-polymorphic binary serialization to ACE CDR. +// + +#include // std::auto_ptr +#include +#include + +#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 r (root (argv[1])); + + // Save to a CDR stream. + // + ACE_OutputCDR ace_ocdr; + xml_schema::ostream ocdr (ace_ocdr); + ocdr << *r; + + // Load from a CDR stream. + // + ACE_InputCDR ace_icdr (ace_ocdr); + xml_schema::istream icdr (ace_icdr); + auto_ptr c (new type (icdr)); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + type::complex_sequence rs (r->complex ()), cs (c->complex ()); + + for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); + ri != rs.end () && ci != rs.end (); ++ri, ++ci) + { + assert (ri->a () == ci->a ()); + if (ri->b ()) + assert (ri->b () == ci->b ()); + assert (ri->c () == ci->c ()); + + assert (ri->x () == ci->x ()); + if (ri->y ()) + assert (ri->y () == ci->y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->year () == c->year ()); + assert (r->month_day () == c->month_day ()); + assert (r->year_month () == c->year_month ()); + assert (r->date () == c->date ()); + assert (r->time () == c->time ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/binary/cdr/makefile b/tests/cxx/tree/binary/cdr/makefile new file mode 100644 index 0000000..3298f18 --- /dev/null +++ b/tests/cxx/tree/binary/cdr/makefile @@ -0,0 +1,86 @@ +# file : tests/cxx/tree/binary/cdr/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(call import,\ + $(scf_root)/import/libace/stub.make,\ + l: ace.l,cpp-options: ace.l.cpp-options) + +# Build. +# +$(driver): $(obj) $(xerces_c.l) $(ace.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) $(ace.l.cpp-options) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--generate-insertion ACE_OutputCDR \ +--generate-extraction ACE_InputCDR + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml + $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/binary/cdr/test.xml b/tests/cxx/tree/binary/cdr/test.xml new file mode 100644 index 0000000..928b4cf --- /dev/null +++ b/tests/cxx/tree/binary/cdr/test.xml @@ -0,0 +1,91 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + diff --git a/tests/cxx/tree/binary/cdr/test.xsd b/tests/cxx/tree/binary/cdr/test.xsd new file mode 100644 index 0000000..e593f64 --- /dev/null +++ b/tests/cxx/tree/binary/cdr/test.xsd @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/binary/makefile b/tests/cxx/tree/binary/makefile new file mode 100644 index 0000000..9d57c0c --- /dev/null +++ b/tests/cxx/tree/binary/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/binary/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := cdr polymorphic xdr + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/binary/polymorphic/driver.cxx b/tests/cxx/tree/binary/polymorphic/driver.cxx new file mode 100644 index 0000000..bd2b0cf --- /dev/null +++ b/tests/cxx/tree/binary/polymorphic/driver.cxx @@ -0,0 +1,151 @@ +// file : tests/cxx/tree/binary/polymorphic/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test polymorphic binary serialization. +// + +#include // std::auto_ptr +#include +#include +#include + +#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 r (root (argv[1])); + + // Save to a CDR stream. + // + ACE_OutputCDR ace_ocdr; + xml_schema::ostream ocdr (ace_ocdr); + ocdr << *r; + + // Load from a CDR stream. + // + ACE_InputCDR ace_icdr (ace_ocdr); + xml_schema::istream icdr (ace_icdr); + auto_ptr c (new type (icdr)); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + { + complex& rc (dynamic_cast (r->base ())); + complex& cc (dynamic_cast (c->base ())); + + assert (rc.a () == cc.a ()); + if (rc.b ()) + assert (rc.b () == cc.b ()); + assert (rc.c () == cc.c ()); + + assert (rc.x () == cc.x ()); + if (rc.y ()) + assert (rc.y () == cc.y ()); + } + + { + complex& rc (dynamic_cast (r->sbase ())); + complex& cc (dynamic_cast (c->sbase ())); + + assert (rc.a () == cc.a ()); + if (rc.b ()) + assert (rc.b () == cc.b ()); + assert (rc.c () == cc.c ()); + + assert (rc.x () == cc.x ()); + if (rc.y ()) + assert (rc.y () == cc.y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->date () == c->date ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->month_day () == c->month_day ()); + assert (r->year () == c->year ()); + assert (r->year_month () == c->year_month ()); + assert (r->time () == c->time ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/binary/polymorphic/makefile b/tests/cxx/tree/binary/polymorphic/makefile new file mode 100644 index 0000000..7a4c667 --- /dev/null +++ b/tests/cxx/tree/binary/polymorphic/makefile @@ -0,0 +1,87 @@ +# file : tests/cxx/tree/binary/polymorphic/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(call import,\ + $(scf_root)/import/libace/stub.make,\ + l: ace.l,cpp-options: ace.l.cpp-options) + +# Build. +# +$(driver): $(obj) $(xerces_c.l) $(ace.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) $(ace.l.cpp-options) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--generate-insertion ACE_OutputCDR \ +--generate-extraction ACE_InputCDR \ +--generate-polymorphic --root-element-last + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml + $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/binary/polymorphic/test.xml b/tests/cxx/tree/binary/polymorphic/test.xml new file mode 100644 index 0000000..ad3a403 --- /dev/null +++ b/tests/cxx/tree/binary/polymorphic/test.xml @@ -0,0 +1,92 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + diff --git a/tests/cxx/tree/binary/polymorphic/test.xsd b/tests/cxx/tree/binary/polymorphic/test.xsd new file mode 100644 index 0000000..8c214e5 --- /dev/null +++ b/tests/cxx/tree/binary/polymorphic/test.xsd @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/binary/xdr/driver.cxx b/tests/cxx/tree/binary/xdr/driver.cxx new file mode 100644 index 0000000..787cfaf --- /dev/null +++ b/tests/cxx/tree/binary/xdr/driver.cxx @@ -0,0 +1,181 @@ +// file : tests/cxx/tree/binary/xdr/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test non-polymorphic binary serialization to XDR. +// + +#include // std::auto_ptr +#include // std::memcpy +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +extern "C" int +overflow (char* p, char* buf, int n) +{ + xml_schema::buffer* dst (reinterpret_cast (p)); + + std::size_t size (dst->size ()); + dst->size (size + n); + memcpy (dst->data () + size, buf, n); + + return n; +} + +struct underflow_info +{ + xml_schema::buffer* buf; + std::size_t pos; +}; + +extern "C" int +underflow (char* p, char* buf, int n) +{ + underflow_info* ui (reinterpret_cast (p)); + + std::size_t size (ui->buf->size () - ui->pos); + n = size > n ? n : size; + + memcpy (buf, ui->buf->data () + ui->pos, n); + ui->pos += n; + + return n; +} + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + auto_ptr r (root (argv[1])); + + // Save to an XDR stream. + // + XDR xdr; + xml_schema::buffer buf; + xdrrec_create (&xdr, 0, 0, reinterpret_cast (&buf), 0, &overflow); + xdr.x_op = XDR_ENCODE; + xsd::cxx::tree::ostream oxdr (xdr); + oxdr << *r; + xdrrec_endofrecord (&xdr, true); // flush the data + xdr_destroy (&xdr); + + // Load from an XDR stream. + // + underflow_info ui; + ui.buf = &buf; + ui.pos = 0; + xdrrec_create (&xdr, 0, 0, reinterpret_cast (&ui), &underflow, 0); + xdr.x_op = XDR_DECODE; + xdrrec_skiprecord (&xdr); + xsd::cxx::tree::istream ixdr (xdr); + auto_ptr c (new type (ixdr)); + xdr_destroy (&xdr); + + // Compare the two. + // + assert (r->list () == c->list ()); + assert (r->union_ () == c->union_ ()); + assert (r->enumeration () == c->enumeration ()); + + type::complex_sequence rs (r->complex ()), cs (c->complex ()); + + for (type::complex_iterator ri (rs.begin ()), ci (cs.begin ()); + ri != rs.end () && ci != rs.end (); ++ri, ++ci) + { + assert (ri->a () == ci->a ()); + if (ri->b ()) + assert (ri->b () == ci->b ()); + assert (ri->c () == ci->c ()); + + assert (ri->x () == ci->x ()); + if (ri->y ()) + assert (ri->y () == ci->y ()); + } + + // integers + // + assert (r->byte () == c->byte ()); + assert (r->unsigned_byte () == c->unsigned_byte ()); + assert (r->short_ () == c->short_ ()); + assert (r->unsigned_short () == c->unsigned_short ()); + assert (r->int_ () == c->int_ ()); + assert (r->unsigned_int () == c->unsigned_int ()); + assert (r->long_ () == c->long_ ()); + assert (r->unsigned_long () == c->unsigned_long ()); + assert (r->integer () == c->integer ()); + assert (r->non_positive_integer () == c->non_positive_integer ()); + assert (r->non_negative_integer () == c->non_negative_integer ()); + assert (r->positive_integer () == c->positive_integer ()); + assert (r->negative_integer () == c->negative_integer ()); + + // boolean + // + assert (r->boolean () == c->boolean ()); + + // floats + // + assert (r->float_ () == c->float_ ()); + assert (r->double_ () == c->double_ ()); + assert (r->decimal () == c->decimal ()); + + // strings + // + assert (r->string () == c->string ()); + assert (r->normalized_string () == c->normalized_string ()); + assert (r->token () == c->token ()); + assert (r->name () == c->name ()); + assert (r->name_token () == c->name_token ()); + assert (r->name_tokens () == c->name_tokens ()); + assert (r->ncname () == c->ncname ()); + assert (r->language () == c->language ()); + + // qualified name + // + assert (r->qname () == c->qname ()); + + // ID/IDREF + // + assert (r->id () == c->id ()); + assert (r->id_ref () == c->id_ref ()); + assert (r->id_refs () == c->id_refs ()); + + // URI + // + assert (r->any_uri () == c->any_uri ()); + + // binary + // + assert (r->base64_binary () == c->base64_binary ()); + assert (r->hex_binary () == c->hex_binary ()); + + // date/time + // + assert (r->date () == c->date ()); + assert (r->date_time () == c->date_time ()); + assert (r->duration () == c->duration ()); + assert (r->day () == c->day ()); + assert (r->month () == c->month ()); + assert (r->month_day () == c->month_day ()); + assert (r->year () == c->year ()); + assert (r->year_month () == c->year_month ()); + assert (r->time () == c->time ()); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/binary/xdr/makefile b/tests/cxx/tree/binary/xdr/makefile new file mode 100644 index 0000000..23cde6b --- /dev/null +++ b/tests/cxx/tree/binary/xdr/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/binary/xdr/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--generate-insertion XDR --generate-extraction XDR + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml + $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/binary/xdr/test.xml b/tests/cxx/tree/binary/xdr/test.xml new file mode 100644 index 0000000..928b4cf --- /dev/null +++ b/tests/cxx/tree/binary/xdr/test.xml @@ -0,0 +1,91 @@ + + + 1 2 3 + + abc + + left + + + aaa + + + aaa + bbb + c + cc + ccc + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 1234567812345678.1234567812345678 + + + + string + normalized string + one two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + diff --git a/tests/cxx/tree/binary/xdr/test.xsd b/tests/cxx/tree/binary/xdr/test.xsd new file mode 100644 index 0000000..e593f64 --- /dev/null +++ b/tests/cxx/tree/binary/xdr/test.xsd @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/built-in/attributes.xml b/tests/cxx/tree/built-in/attributes.xml new file mode 100644 index 0000000..609a757 --- /dev/null +++ b/tests/cxx/tree/built-in/attributes.xml @@ -0,0 +1,73 @@ + + 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 +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test built-in type mapping. +// + +#include // std::auto_ptr +#include +#include + + +#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 elements (xmlns::test::elements (argv[1])); + + auto_ptr attributes ( + xmlns::test::attributes (argv[2])); + + auto_ptr 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 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 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 inherited1 ( + xmlns::test::inherited (istr)); + + std::ostringstream ostr1; + xmlns::test::inherited (ostr1, *inherited1, map); + + if (ostr.str () != ostr1.str ()) + return 1; + } +} diff --git a/tests/cxx/tree/built-in/elements.xml b/tests/cxx/tree/built-in/elements.xml new file mode 100644 index 0000000..f76f019 --- /dev/null +++ b/tests/cxx/tree/built-in/elements.xml @@ -0,0 +1,84 @@ + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized +string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + diff --git a/tests/cxx/tree/built-in/inherited.xml b/tests/cxx/tree/built-in/inherited.xml new file mode 100644 index 0000000..1781a69 --- /dev/null +++ b/tests/cxx/tree/built-in/inherited.xml @@ -0,0 +1,84 @@ + + + + + 65 + 66 + -222 + 57005 + -57005 + 3735928559 + -3735928559 + 16045690984833335023 + -3735928559 + -3735928559 + 3735928559 + 3735928559 + -3735928559 + + + + true + + + + 1234.1234 + 12345678.12345678 + 12345678.12345678 + + + + string + normalized +string + + one + two three + name + name-token + name tokens + ncname + en-us + + + xsi:schemaLocation + + + + elements1 + elements2 + elements1 + elements1 elements2 + + + + http://www.codesynthesis.com + + + + YmFzZTY0IGJpbmFyeQ== + 6865782052696E617279 + + + + 2001-10-26+02:00 + 2001-10-26T21:32:52+02:00 + P1Y2M3DT5H20M30S + ---01+02:00 + --11+02:00 + --11-02+02:00 + 2001+02:00 + 2001-11+02:00 + + + + + + + diff --git a/tests/cxx/tree/built-in/makefile b/tests/cxx/tree/built-in/makefile new file mode 100644 index 0000000..028d18d --- /dev/null +++ b/tests/cxx/tree/built-in/makefile @@ -0,0 +1,93 @@ +# file : tests/cxx/tree/built-in/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := types.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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --char-type char \ + --generate-inline \ + --generate-ostream \ + --generate-serialization \ + --generate-default-ctor \ + --generate-from-base-ctor \ + --root-element-all + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(src_root)/xsd/xsd + +$(call include-dep,$(dep)) + + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +# We need to cd to src_base in order to have the schema in the working +# directory. +# +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/elements.xml $(src_base)/attributes.xml \ +$(src_base)/inherited.xml + cd $(src_base) && $(driver) $(src_base)/elements.xml \ +$(src_base)/attributes.xml $(src_base)/inherited.xml + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/built-in/types.xsd b/tests/cxx/tree/built-in/types.xsd new file mode 100644 index 0000000..22582cb --- /dev/null +++ b/tests/cxx/tree/built-in/types.xsd @@ -0,0 +1,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/chameleon/driver.cxx b/tests/cxx/tree/chameleon/driver.cxx new file mode 100644 index 0000000..944b486 --- /dev/null +++ b/tests/cxx/tree/chameleon/driver.cxx @@ -0,0 +1,37 @@ +// file : tests/cxx/tree/chameleon/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test chameleon inclusion. +// + +#include // std::auto_ptr +#include + +#include "includer.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 r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/chameleon/includee.xsd b/tests/cxx/tree/chameleon/includee.xsd new file mode 100644 index 0000000..531a7d0 --- /dev/null +++ b/tests/cxx/tree/chameleon/includee.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/cxx/tree/chameleon/includer.xsd b/tests/cxx/tree/chameleon/includer.xsd new file mode 100644 index 0000000..a1c850a --- /dev/null +++ b/tests/cxx/tree/chameleon/includer.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/tests/cxx/tree/chameleon/makefile b/tests/cxx/tree/chameleon/makefile new file mode 100644 index 0000000..bd7aa2c --- /dev/null +++ b/tests/cxx/tree/chameleon/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/chameleon/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := includer.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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --root-element root \ +--generate-ostream + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/chameleon/output b/tests/cxx/tree/chameleon/output new file mode 100644 index 0000000..c40f715 --- /dev/null +++ b/tests/cxx/tree/chameleon/output @@ -0,0 +1,3 @@ + +a: a +b: b diff --git a/tests/cxx/tree/chameleon/test.xml b/tests/cxx/tree/chameleon/test.xml new file mode 100644 index 0000000..12ff279 --- /dev/null +++ b/tests/cxx/tree/chameleon/test.xml @@ -0,0 +1,8 @@ + + + a + b + + diff --git a/tests/cxx/tree/comparison/driver.cxx b/tests/cxx/tree/comparison/driver.cxx new file mode 100644 index 0000000..eda2b59 --- /dev/null +++ b/tests/cxx/tree/comparison/driver.cxx @@ -0,0 +1,40 @@ +// file : tests/cxx/tree/comparison/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test generated comparison operators. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + type::complex_sequence s (r->complex ()); + + assert (s[0] == s[0]); + assert (s[0] != s[1]); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/comparison/makefile b/tests/cxx/tree/comparison/makefile new file mode 100644 index 0000000..ac4ad8c --- /dev/null +++ b/tests/cxx/tree/comparison/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/comparison/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-comparison + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml + $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/comparison/test.xml b/tests/cxx/tree/comparison/test.xml new file mode 100644 index 0000000..b5d8158 --- /dev/null +++ b/tests/cxx/tree/comparison/test.xml @@ -0,0 +1,19 @@ + + + + 123 + abc + abc + def + + + + 123 + abc + abc + xyz + + + diff --git a/tests/cxx/tree/comparison/test.xsd b/tests/cxx/tree/comparison/test.xsd new file mode 100644 index 0000000..c234add --- /dev/null +++ b/tests/cxx/tree/comparison/test.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/compilation/driver.cxx b/tests/cxx/tree/compilation/driver.cxx new file mode 100644 index 0000000..bb9f8cb --- /dev/null +++ b/tests/cxx/tree/compilation/driver.cxx @@ -0,0 +1,119 @@ +// file : tests/cxx/tree/compilation/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Make sure the runtime library compiles by explicitly instantiating +// all the types. +// + +#include // std::auto_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +template class xsd::cxx::tree::simple_type; + +// String types. +// +template class xsd::cxx::tree::string< char, xml_schema::simple_type >; +template class xsd::cxx::tree::normalized_string< char, xml_schema::string >; +template class xsd::cxx::tree::token< char, xml_schema::normalized_string >; +template class xsd::cxx::tree::name< char, xml_schema::token >; +template class xsd::cxx::tree::nmtoken< char, xml_schema::token >; +template class xsd::cxx::tree::nmtokens< char, xml_schema::simple_type, xml_schema::nmtoken >; +template class xsd::cxx::tree::ncname< char, xml_schema::name >; +template class xsd::cxx::tree::language< char, xml_schema::token >; + +// ID/IDREF. +// +template class xsd::cxx::tree::id< char, xml_schema::ncname >; +template class xsd::cxx::tree::idref< xml_schema::type, char, xml_schema::ncname >; +template class xsd::cxx::tree::idrefs< char, xml_schema::simple_type, xml_schema::idref >; + +// URI. +// +template class xsd::cxx::tree::uri< char, xml_schema::simple_type >; + +// Qualified name. +// +template class xsd::cxx::tree::qname< char, xml_schema::simple_type, xml_schema::uri, xml_schema::ncname >; + +// Binary. +// +template class xsd::cxx::tree::buffer< char >; +template class xsd::cxx::tree::base64_binary< char, xml_schema::simple_type >; +template class xsd::cxx::tree::hex_binary< char, xml_schema::simple_type >; + +// Date/time. +// +template class xsd::cxx::tree::date< char, xml_schema::simple_type >; +template class xsd::cxx::tree::date_time< char, xml_schema::simple_type >; +template class xsd::cxx::tree::duration< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gday< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gmonth< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gmonth_day< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gyear< char, xml_schema::simple_type >; +template class xsd::cxx::tree::gyear_month< char, xml_schema::simple_type >; +template class xsd::cxx::tree::time< char, xml_schema::simple_type >; + +// Entity. +// +template class xsd::cxx::tree::entity< char, xml_schema::ncname >; +template class xsd::cxx::tree::entities< char, xml_schema::simple_type, xml_schema::entity >; + +// Namespace information and list stream. Used in +// serialization functions. +// +template class xsd::cxx::xml::dom::namespace_info < char >; +template class xsd::cxx::xml::dom::namespace_infomap < char >; +template class xsd::cxx::tree::list_stream < char >; + +// Flags and properties. +// +template class xsd::cxx::tree::properties< char >; + +// Exceptions. +// +template class xsd::cxx::tree::exception< char >; +template class xsd::cxx::tree::parsing< char >; +template class xsd::cxx::tree::expected_element< char >; +template class xsd::cxx::tree::unexpected_element< char >; +template class xsd::cxx::tree::expected_attribute< char >; +template class xsd::cxx::tree::unexpected_enumerator< char >; +template class xsd::cxx::tree::expected_text_content< char >; +template class xsd::cxx::tree::no_type_info< char >; +template class xsd::cxx::tree::not_derived< char >; +template class xsd::cxx::tree::duplicate_id< char >; +template class xsd::cxx::tree::serialization< char >; +template class xsd::cxx::tree::no_prefix_mapping< char >; +template class xsd::cxx::tree::bounds< char >; + +// Parsing/serialization diagnostics. +// +template class xsd::cxx::tree::error< char >; +template class xsd::cxx::tree::diagnostics< char >; + +// Error handler interface. +// +template class xsd::cxx::xml::error_handler< char >; + + +// +// +template class xsd::cxx::tree::fundamental_base; +template class xsd::cxx::tree::one; +template class xsd::cxx::tree::one; +template class xsd::cxx::tree::optional; +template class xsd::cxx::tree::optional; +template class xsd::cxx::tree::sequence; +template class xsd::cxx::tree::sequence; + + +int +main () +{ +} diff --git a/tests/cxx/tree/compilation/makefile b/tests/cxx/tree/compilation/makefile new file mode 100644 index 0000000..fcb6e15 --- /dev/null +++ b/tests/cxx/tree/compilation/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/compilation/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-serialization + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/compilation/test.xsd b/tests/cxx/tree/compilation/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/tests/cxx/tree/compilation/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/cxx/tree/complex/ctor/driver.cxx b/tests/cxx/tree/complex/ctor/driver.cxx new file mode 100644 index 0000000..a46bac8 --- /dev/null +++ b/tests/cxx/tree/complex/ctor/driver.cxx @@ -0,0 +1,112 @@ +// file : tests/cxx/tree/complex/ctor/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test generation of varous complex type constructors. +// + +#include +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test case A. + // + { + a_base b1; + a_base b2 ("abc"); // empty ultimate base + required + a_base b3 ("abc", "foo"); // ultimate base + required + + a_derived a1; + a_derived a2 ("foo", "bar"); // empty ultimate base + required + a_derived a3 (b3, "bar"); // base + required + a_derived a4 ("abc", "foo", "bar"); // ultimate base + required + } + + // Test case B. + // + { + b_simple s ("base"); + b_base b ("base", "foo"); + b_derived d ("base", "foo", "bar"); + b_type t ("base"); + } + + // Test case C. + // + { + c_simple s (c_enum::a); + c_base b (c_enum::a, "foo"); + c_derived d (c_enum::a, "foo", "bar"); + c_type t (c_enum::a); + } + + // Test case D. + // + { + d_simple s (1); + d_base b (1, "foo"); + d_derived d (1, "foo", "bar"); + d_type t (1); + } + + // Test case E. + // + { + // e_base + // + e_base b1 (1, "foo", e_complex_type ("bar")); + + auto_ptr c2 (new e_complex_type ("bar")); + e_base b2 (1, "foo", c2); + + auto_ptr s3 (new e_simple_type ("foo")); + auto_ptr c3 (new e_complex_type ("bar")); + e_base b3 (1, s3, c3); + + assert (b1 == b2); + assert (b1 == b3); + + // e_derived + // + e_derived d1 (1, "foo", e_complex_type ("bar"), + true, "baz", e_complex_type ("biz")); + + auto_ptr c2a (new e_complex_type ("bar")); + auto_ptr c2b (new e_complex_type ("biz")); + e_derived d2 (1, "foo", c2a, true, "baz", c2b); + + auto_ptr s3a (new e_simple_type ("foo")); + auto_ptr s3b (new xml_schema::string ("baz")); + auto_ptr c3a (new e_complex_type ("bar")); + auto_ptr c3b (new e_complex_type ("biz")); + e_derived d3 (1, s3a, c3a, true, s3b, c3b); + + assert (d1 == d2); + assert (d1 == d3); + + } + + // Test case F. + // + { + f_type f1 (xml_schema::type (), 1, "foo", f_complex_type ("bar")); + + auto_ptr c2 (new f_complex_type ("bar")); + f_type f2 (1, "foo", c2); + + auto_ptr s3 (new f_simple_type ("foo")); + auto_ptr c3 (new f_complex_type ("bar")); + f_type f3 (1, s3, c3); + + assert (f1 == f2); + assert (f1 == f3); + } +} diff --git a/tests/cxx/tree/complex/ctor/makefile b/tests/cxx/tree/complex/ctor/makefile new file mode 100644 index 0000000..4894a6f --- /dev/null +++ b/tests/cxx/tree/complex/ctor/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/complex/ctor/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \ +--generate-from-base-ctor --generate-doxygen --generate-polymorphic \ +--generate-comparison + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/complex/ctor/test.xsd b/tests/cxx/tree/complex/ctor/test.xsd new file mode 100644 index 0000000..b8dd95e --- /dev/null +++ b/tests/cxx/tree/complex/ctor/test.xsd @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/complex/makefile b/tests/cxx/tree/complex/makefile new file mode 100644 index 0000000..ed6e5de --- /dev/null +++ b/tests/cxx/tree/complex/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/complex/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := ctor + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/containment/driver.cxx b/tests/cxx/tree/containment/driver.cxx new file mode 100644 index 0000000..bd9aa24 --- /dev/null +++ b/tests/cxx/tree/containment/driver.cxx @@ -0,0 +1,77 @@ +// file : tests/cxx/tree/test-template/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test tree node containment. +// + +#include // std::auto_ptr + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Change of a container in a sub-tree without ID. + // + { + auto_ptr i (new inner ()); + i->ref ("foo"); + + outer o; + o.i (i); + o.ref ("foo"); + + assert (o.i ()->ref ()->get () == 0); + assert (o.ref ()->get () == 0); + } + + // Change of container in a sub-tree with ID inside. + // + { + auto_ptr i (new inner ()); + inner* p (i.get ()); + i->id ("foo"); + i->ref ("foo"); + assert (i->ref ()->get () == p); + + outer o; + o.i (i); + o.ref ("foo"); + + assert (o.i ()->ref ()->get () == p); + assert (o.ref ()->get () == p); + } + + // Change of a container in ID. + // + { + auto_ptr id (new xml_schema::id ("foo")); + + inner i; + i.id (id); + i.ref ("foo"); + assert (i.ref ()->get () == &i); + } + + // Change of a container in a type derived from ID with ID inside. + // + { + auto_ptr id (new id_ex ("foo")); + id_ex* p (id.get ()); + id->id ("bar"); + + inner i; + i.id_ex (id); + + i.ref ("foo"); + assert (i.ref ()->get () == &i); + + i.ref ("bar"); + assert (i.ref ()->get () == p); + } +} diff --git a/tests/cxx/tree/containment/makefile b/tests/cxx/tree/containment/makefile new file mode 100644 index 0000000..e29e93a --- /dev/null +++ b/tests/cxx/tree/containment/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/containment/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/containment/test.xsd b/tests/cxx/tree/containment/test.xsd new file mode 100644 index 0000000..002bdda --- /dev/null +++ b/tests/cxx/tree/containment/test.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/default/driver.cxx b/tests/cxx/tree/default/driver.cxx new file mode 100644 index 0000000..3c71222 --- /dev/null +++ b/tests/cxx/tree/default/driver.cxx @@ -0,0 +1,48 @@ +// file : tests/cxx/tree/default/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test default attribute/element values. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1], xml_schema::flags::dont_validate)); + + cout << *r << endl + << "default x: " << derived::x_default_value () << endl + << "default y: " << derived::y_default_value () << endl + << "fixed p: " << derived::p_default_value () << endl + << "fixed q1: " << derived::q1_default_value () << endl + << "fixed q2: " << derived::q2_default_value () << endl; + + // Serialize. + // + xml_schema::namespace_infomap map; + map["t"].name = "test"; + root (cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/default/makefile b/tests/cxx/tree/default/makefile new file mode 100644 index 0000000..209c283 --- /dev/null +++ b/tests/cxx/tree/default/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/default/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-ostream \ +--generate-serialization --generate-default-ctor --generate-from-base-ctor \ +--omit-default-attributes + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/default/output b/tests/cxx/tree/default/output new file mode 100644 index 0000000..1259952 --- /dev/null +++ b/tests/cxx/tree/default/output @@ -0,0 +1,26 @@ + +derived: +a: a +x: foo +q1: 1 +y: -20 +p: bar +q2: 2 +qname: +x: x +y: y +default x: foo +default y: -20 +fixed p: bar +fixed q1: 1 +fixed q2: 2 + + + + + a + + + + + diff --git a/tests/cxx/tree/default/test.xml b/tests/cxx/tree/default/test.xml new file mode 100644 index 0000000..d568ac9 --- /dev/null +++ b/tests/cxx/tree/default/test.xml @@ -0,0 +1,11 @@ + + + + a + + + + + diff --git a/tests/cxx/tree/default/test.xsd b/tests/cxx/tree/default/test.xsd new file mode 100644 index 0000000..aa9ac66 --- /dev/null +++ b/tests/cxx/tree/default/test.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/encoding/char/lcp/driver.cxx b/tests/cxx/tree/encoding/char/lcp/driver.cxx new file mode 100644 index 0000000..3d30aa9 --- /dev/null +++ b/tests/cxx/tree/encoding/char/lcp/driver.cxx @@ -0,0 +1,42 @@ +// file : tests/cxx/tree/encoding/char/lcp/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test local code page encoding (XSD_USE_LCP defined). +// The test just makes sure it still compiles and works. +// + +#include // std::auto_ptr +#include +#include + +#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 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/tests/cxx/tree/encoding/char/lcp/makefile b/tests/cxx/tree/encoding/char/lcp/makefile new file mode 100644 index 0000000..8560e92 --- /dev/null +++ b/tests/cxx/tree/encoding/char/lcp/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/encoding/char/lcp/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 -DXSD_USE_LCP +$(obj) $(dep): $(xerces_c.l.cpp-options) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-serialization + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(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. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/encoding/char/lcp/test.std b/tests/cxx/tree/encoding/char/lcp/test.std new file mode 100644 index 0000000..cc20ef7 --- /dev/null +++ b/tests/cxx/tree/encoding/char/lcp/test.std @@ -0,0 +1,6 @@ + + + + abcd + + diff --git a/tests/cxx/tree/encoding/char/lcp/test.xml b/tests/cxx/tree/encoding/char/lcp/test.xml new file mode 100644 index 0000000..772512e --- /dev/null +++ b/tests/cxx/tree/encoding/char/lcp/test.xml @@ -0,0 +1,7 @@ + + + abcd + + diff --git a/tests/cxx/tree/encoding/char/lcp/test.xsd b/tests/cxx/tree/encoding/char/lcp/test.xsd new file mode 100644 index 0000000..1e264e3 --- /dev/null +++ b/tests/cxx/tree/encoding/char/lcp/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/cxx/tree/encoding/char/makefile b/tests/cxx/tree/encoding/char/makefile new file mode 100644 index 0000000..c69fc44 --- /dev/null +++ b/tests/cxx/tree/encoding/char/makefile @@ -0,0 +1,22 @@ +# file : tests/cxx/tree/encoding/char/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/encoding/char/utf-8/driver.cxx b/tests/cxx/tree/encoding/char/utf-8/driver.cxx new file mode 100644 index 0000000..45a5fd1 --- /dev/null +++ b/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 +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test UTF-8 encoding. +// + +#include // std::auto_ptr +#include +#include + +#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 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/tests/cxx/tree/encoding/char/utf-8/makefile b/tests/cxx/tree/encoding/char/utf-8/makefile new file mode 100644 index 0000000..0aa5884 --- /dev/null +++ b/tests/cxx/tree/encoding/char/utf-8/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/encoding/char/lcp/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-serialization \ +--generate-doxygen + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(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. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/encoding/char/utf-8/test.std b/tests/cxx/tree/encoding/char/utf-8/test.std new file mode 100644 index 0000000..328fe6d Binary files /dev/null and b/tests/cxx/tree/encoding/char/utf-8/test.std differ diff --git a/tests/cxx/tree/encoding/char/utf-8/test.xml b/tests/cxx/tree/encoding/char/utf-8/test.xml new file mode 100644 index 0000000..a6e5d99 --- /dev/null +++ b/tests/cxx/tree/encoding/char/utf-8/test.xml @@ -0,0 +1,15 @@ + + + abc + Օ + + 򪪪 + + abc + aՕc + ꪪbc + ab򪪪 + + diff --git a/tests/cxx/tree/encoding/char/utf-8/test.xsd b/tests/cxx/tree/encoding/char/utf-8/test.xsd new file mode 100644 index 0000000..6c32a32 --- /dev/null +++ b/tests/cxx/tree/encoding/char/utf-8/test.xsd @@ -0,0 +1,33 @@ + + + + + + + + Test enum. Valid values are: + abc + aՕc + ꪪbc + ab򪪪 + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/encoding/makefile b/tests/cxx/tree/encoding/makefile new file mode 100644 index 0000000..5e0803e --- /dev/null +++ b/tests/cxx/tree/encoding/makefile @@ -0,0 +1,22 @@ +# file : tests/cxx/tree/encoding/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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 + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/encoding/wchar/driver.cxx b/tests/cxx/tree/encoding/wchar/driver.cxx new file mode 100644 index 0000000..0707cc3 --- /dev/null +++ b/tests/cxx/tree/encoding/wchar/driver.cxx @@ -0,0 +1,57 @@ +// file : tests/cxx/tree/encoding/wchar/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test the wide character mapping. +// + +#include // std::auto_ptr +#include +#include + +#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 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/tests/cxx/tree/encoding/wchar/makefile b/tests/cxx/tree/encoding/wchar/makefile new file mode 100644 index 0000000..bf2e57d --- /dev/null +++ b/tests/cxx/tree/encoding/wchar/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/encoding/wchar/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-serialization \ +--generate-doxygen --char-type wchar_t + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(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. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/encoding/wchar/test.std b/tests/cxx/tree/encoding/wchar/test.std new file mode 100644 index 0000000..93d4561 Binary files /dev/null and b/tests/cxx/tree/encoding/wchar/test.std differ diff --git a/tests/cxx/tree/encoding/wchar/test.xml b/tests/cxx/tree/encoding/wchar/test.xml new file mode 100644 index 0000000..c6ec850 --- /dev/null +++ b/tests/cxx/tree/encoding/wchar/test.xml @@ -0,0 +1,14 @@ + + + abc + ῿퟿ + 𐀀􏿽 + + abc + a῿퟿c + 𐀀􏿽bc + ab𐀀􏿽 + + diff --git a/tests/cxx/tree/encoding/wchar/test.xsd b/tests/cxx/tree/encoding/wchar/test.xsd new file mode 100644 index 0000000..0bf4bdd --- /dev/null +++ b/tests/cxx/tree/encoding/wchar/test.xsd @@ -0,0 +1,33 @@ + + + + + + + + Test enum. Valid values are: + abc + a῿퟿c + 𐀀􏿽bc + ab𐀀􏿽 + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/enumeration/ctor/driver.cxx b/tests/cxx/tree/enumeration/ctor/driver.cxx new file mode 100644 index 0000000..238d446 --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/driver.cxx @@ -0,0 +1,32 @@ +// file : tests/cxx/tree/enumeration/ctor/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test enumeration constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor(const char*). + // + { + string_enum se ("a"); + type t ("a", 1); + } + + // Test ctor(const std::string&) + // + { + string const s ("c"); + string_enum se (s); + type t (s, 3); + } +} diff --git a/tests/cxx/tree/enumeration/ctor/makefile b/tests/cxx/tree/enumeration/ctor/makefile new file mode 100644 index 0000000..3ea7b8e --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/enumeration/ctor/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \ +--generate-from-base-ctor --generate-doxygen + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/enumeration/ctor/test.xsd b/tests/cxx/tree/enumeration/ctor/test.xsd new file mode 100644 index 0000000..c5d625a --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/test.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/enumeration/inheritance/driver.cxx b/tests/cxx/tree/enumeration/inheritance/driver.cxx new file mode 100644 index 0000000..af67afb --- /dev/null +++ b/tests/cxx/tree/enumeration/inheritance/driver.cxx @@ -0,0 +1,49 @@ +// file : tests/cxx/tree/enumeration/inheritance/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + switch (*r) + { + case top_bottom::top: + { + cout << "top" << endl; + break; + } + case top_bottom::bottom: + { + cout << "bottom" << endl; + break; + } + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/enumeration/inheritance/makefile b/tests/cxx/tree/enumeration/inheritance/makefile new file mode 100644 index 0000000..0af9733 --- /dev/null +++ b/tests/cxx/tree/enumeration/inheritance/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/enumeration/inheritance/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-ostream + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/enumeration/inheritance/output b/tests/cxx/tree/enumeration/inheritance/output new file mode 100644 index 0000000..fef12e2 --- /dev/null +++ b/tests/cxx/tree/enumeration/inheritance/output @@ -0,0 +1 @@ +bottom diff --git a/tests/cxx/tree/enumeration/inheritance/test.xml b/tests/cxx/tree/enumeration/inheritance/test.xml new file mode 100644 index 0000000..1de9043 --- /dev/null +++ b/tests/cxx/tree/enumeration/inheritance/test.xml @@ -0,0 +1,3 @@ +bottom diff --git a/tests/cxx/tree/enumeration/inheritance/test.xsd b/tests/cxx/tree/enumeration/inheritance/test.xsd new file mode 100644 index 0000000..cf2eeb1 --- /dev/null +++ b/tests/cxx/tree/enumeration/inheritance/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/enumeration/makefile b/tests/cxx/tree/enumeration/makefile new file mode 100644 index 0000000..87cab57 --- /dev/null +++ b/tests/cxx/tree/enumeration/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/enumeration/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := ctor inheritance + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/float/driver.cxx b/tests/cxx/tree/float/driver.cxx new file mode 100644 index 0000000..336c731 --- /dev/null +++ b/tests/cxx/tree/float/driver.cxx @@ -0,0 +1,55 @@ +// file : tests/cxx/tree/float/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test floating point (xsd:{float, double, decimal}) type parsing +// and serialization. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + r->simple ().push_back (12.129456); + r->simple ().push_back (123.129456); + r->simple ().push_back (1234.129456); + + r->s (12.129456); + + r->complex ().push_back (12.129456); + r->complex ().push_back (123.129456); + r->complex ().push_back (1234.129456); + r->complex ().push_back (-12.12); + r->complex ().push_back (-123.12); + + r->s (12.129456); + + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + root (cout, *r, map); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/float/makefile b/tests/cxx/tree/float/makefile new file mode 100644 index 0000000..a847ad5 --- /dev/null +++ b/tests/cxx/tree/float/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/float/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-serialization --root-element-all + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(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. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/float/test.std b/tests/cxx/tree/float/test.std new file mode 100644 index 0000000..44264c2 --- /dev/null +++ b/tests/cxx/tree/float/test.std @@ -0,0 +1,68 @@ + + + + 0 + + 1 + + 1e+06 + + 1e-07 + + 0 1 1e+06 1e-07 + + 0 + + 1 + + 100000000000000 + + 1e-15 + + 0 1 100000000000000 1e-15 + + 0 + + 1 + + 10000 + + 100000000000000 + + 0.000000000000001 + + 0 1 100000000000000 0.000000000000001 + + 0 + + 1 + + 12.34 + + 0.12 + + 12.13 + + 123.1 + + 1234 + + 0 + + 1 + + 12.34 + + 0.12 + + 12.13 + + 123.1 + + 1234 + + -12.12 + + -123.1 + + diff --git a/tests/cxx/tree/float/test.xml b/tests/cxx/tree/float/test.xml new file mode 100644 index 0000000..e5124a4 --- /dev/null +++ b/tests/cxx/tree/float/test.xml @@ -0,0 +1,35 @@ + + + 0.0 + 1.0 + 1000000.0 + 0.0000001 + 0.0 1.0 1000000.0 0.0000001 + + 0.0 + 1.0 + 100000000000000.0 + 0.000000000000001 + 0.0 1.0 100000000000000.0 0.000000000000001 + + 0.0 + 1.0 + 10000 + 100000000000000.0 + 0.000000000000001 + 0.0 1.0 100000000000000.0 0.000000000000001 + + 0.0 + 1.0 + 12.34 + 0.12 + + 0.0 + 1.0 + 12.34 + 0.12 + + diff --git a/tests/cxx/tree/float/test.xsd b/tests/cxx/tree/float/test.xsd new file mode 100644 index 0000000..c02678d --- /dev/null +++ b/tests/cxx/tree/float/test.xsd @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/list/ctor/driver.cxx b/tests/cxx/tree/list/ctor/driver.cxx new file mode 100644 index 0000000..0cac51c --- /dev/null +++ b/tests/cxx/tree/list/ctor/driver.cxx @@ -0,0 +1,52 @@ +// file : tests/cxx/tree/list/ctor/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test list constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor() + // + { + string_list sl; + + xml_schema::nmtokens nt; + xml_schema::idrefs id; + } + + // Test ctor(size_type, const X&) + // + { + string_list sl (10, "abc"); + size_type st (10, 123); + + xml_schema::nmtokens nt (10, "abc"); + xml_schema::idrefs id (10, "abc"); + } + + // Test ctor(const I& begin, const I& end) + // + { + string_list sl1 (10, "abc"); + string_list sl2 (sl1.begin (), sl1.end ()); + + I i1 (10, 123); + I i2 (i1.begin (), i1.end ()); + + xml_schema::nmtokens nt1 (10, "abc"); + xml_schema::nmtokens nt2 (nt1.begin (), nt1.end ()); + + xml_schema::idrefs id1 (10, "abc"); + xml_schema::idrefs id2 (id1.begin (), id1.end ()); + } +} diff --git a/tests/cxx/tree/list/ctor/makefile b/tests/cxx/tree/list/ctor/makefile new file mode 100644 index 0000000..1a002ae --- /dev/null +++ b/tests/cxx/tree/list/ctor/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/list/ctor/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \ +--generate-from-base-ctor --generate-doxygen + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/list/ctor/test.xsd b/tests/cxx/tree/list/ctor/test.xsd new file mode 100644 index 0000000..f090bb8 --- /dev/null +++ b/tests/cxx/tree/list/ctor/test.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/list/makefile b/tests/cxx/tree/list/makefile new file mode 100644 index 0000000..9d03a72 --- /dev/null +++ b/tests/cxx/tree/list/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/list/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := ctor + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/makefile b/tests/cxx/tree/makefile new file mode 100644 index 0000000..2d41e54 --- /dev/null +++ b/tests/cxx/tree/makefile @@ -0,0 +1,43 @@ +# file : tests/cxx/tree/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +tests := \ +built-in \ +chameleon \ +comparison \ +compilation \ +complex \ +containment \ +default \ +encoding \ +enumeration \ +float \ +list \ +name-clash \ +naming \ +polymorphism \ +prefix \ +test-template \ +types-only \ +union \ +wildcard + +ifeq ($(xsd_with_ace),y) +tests += binary +endif + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/name-clash/inheritance/driver.cxx b/tests/cxx/tree/name-clash/inheritance/driver.cxx new file mode 100644 index 0000000..47f70b7 --- /dev/null +++ b/tests/cxx/tree/name-clash/inheritance/driver.cxx @@ -0,0 +1,37 @@ +// file : tests/cxx/tree/name-clash/inheritance/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test for name clashes across inheritance hierarchy. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/name-clash/inheritance/makefile b/tests/cxx/tree/name-clash/inheritance/makefile new file mode 100644 index 0000000..aea6a21 --- /dev/null +++ b/tests/cxx/tree/name-clash/inheritance/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/name-clash/inheritance/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-ostream + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/name-clash/inheritance/output b/tests/cxx/tree/name-clash/inheritance/output new file mode 100644 index 0000000..54565bb --- /dev/null +++ b/tests/cxx/tree/name-clash/inheritance/output @@ -0,0 +1,3 @@ + +e: e +e: e1 diff --git a/tests/cxx/tree/name-clash/inheritance/test.xml b/tests/cxx/tree/name-clash/inheritance/test.xml new file mode 100644 index 0000000..8c17101 --- /dev/null +++ b/tests/cxx/tree/name-clash/inheritance/test.xml @@ -0,0 +1,8 @@ + + + e + e1 + + diff --git a/tests/cxx/tree/name-clash/inheritance/test.xsd b/tests/cxx/tree/name-clash/inheritance/test.xsd new file mode 100644 index 0000000..b83d7df --- /dev/null +++ b/tests/cxx/tree/name-clash/inheritance/test.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/name-clash/makefile b/tests/cxx/tree/name-clash/makefile new file mode 100644 index 0000000..5ba6f26 --- /dev/null +++ b/tests/cxx/tree/name-clash/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/name-clash/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := inheritance + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/naming/camel/driver.cxx b/tests/cxx/tree/naming/camel/driver.cxx new file mode 100644 index 0000000..4958e32 --- /dev/null +++ b/tests/cxx/tree/naming/camel/driver.cxx @@ -0,0 +1,145 @@ +// file : tests/cxx/tree/naming/camel/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test camel case (upper for types, lower for functions) naming style. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + Gender::Value v; + v = Gender::female; + } + + // Anonymous type. + // + { + Foo f ("a", "b"); + + if (f.a () != "a" || f.b () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + Type t ("bar"); + + // foo + // + { + Type::FooType* p = 0; + Type::FooOptional o; + + if (t.foo ().present ()) + return 1; + + t.foo (o); + } + + // bar + // + { + Type::BarType* p = 0; + + if (t.bar () != "bar") + return 1; + + t.bar ("barbar"); + } + + // baz + // + { + Type::BazType* p = 0; + Type::BazSequence s; + Type::BazIterator i (s.begin ()); + Type::BazConstIterator ci (s.begin ()); + + if (t.baz () != s) + return 1; + + t.baz (s); + } + + // any + // + { + Type::AnySequence s (t.domDocument ()); + Type::AnyIterator i (s.begin ()); + Type::AnyConstIterator ci (s.begin ()); + + if (t.any () != s) + return 1; + + t.any (s); + } + + // foo + // + { + Type::FoxType x = Type::foxDefaultValue (); + + if (t.fox () != x) + return 1; + + t.fox ("fox"); + } + + // any_attribute + // + { + Type::AnyAttributeSet s (t.domDocument ()); + Type::AnyAttributeIterator i (s.begin ()); + Type::AnyAttributeConstIterator ci (s.begin ()); + + if (t.anyAttribute () != s) + return 1; + + t.anyAttribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + root (is, xml_schema::Flags::dont_validate); + } + + { + ostringstream os; + xml_schema::NamespaceInfomap m; + m["t"].name = "test"; + + root (os, "foo", m); + } + } + catch (xml_schema::Exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/tests/cxx/tree/naming/camel/makefile b/tests/cxx/tree/naming/camel/makefile new file mode 100644 index 0000000..c308a41 --- /dev/null +++ b/tests/cxx/tree/naming/camel/makefile @@ -0,0 +1,87 @@ +# file : tests/cxx/tree/naming/camel/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--type-naming ucc \ +--function-naming lcc \ +--generate-ostream \ +--generate-serialization \ +--generate-comparison \ +--generate-wildcard + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/naming/camel/test.xsd b/tests/cxx/tree/naming/camel/test.xsd new file mode 100644 index 0000000..7d0a745 --- /dev/null +++ b/tests/cxx/tree/naming/camel/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/naming/java/driver.cxx b/tests/cxx/tree/naming/java/driver.cxx new file mode 100644 index 0000000..413ef70 --- /dev/null +++ b/tests/cxx/tree/naming/java/driver.cxx @@ -0,0 +1,145 @@ +// file : tests/cxx/tree/naming/java/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test Java naming style. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + Gender::Value v; + v = Gender::female; + } + + // Anonymous type. + // + { + Foo f ("a", "b"); + + if (f.getA () != "a" || f.getB () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + Type t ("bar"); + + // foo + // + { + Type::FooType* p = 0; + Type::FooOptional o; + + if (t.getFoo ().present ()) + return 1; + + t.setFoo (o); + } + + // bar + // + { + Type::BarType* p = 0; + + if (t.getBar () != "bar") + return 1; + + t.setBar ("barbar"); + } + + // baz + // + { + Type::BazType* p = 0; + Type::BazSequence s; + Type::BazIterator i (s.begin ()); + Type::BazConstIterator ci (s.begin ()); + + if (t.getBaz () != s) + return 1; + + t.setBaz (s); + } + + // any + // + { + Type::AnySequence s (t.getDomDocument ()); + Type::AnyIterator i (s.begin ()); + Type::AnyConstIterator ci (s.begin ()); + + if (t.getAny () != s) + return 1; + + t.setAny (s); + } + + // foo + // + { + Type::FoxType x = Type::getFoxDefaultValue (); + + if (t.getFox () != x) + return 1; + + t.setFox ("fox"); + } + + // any_attribute + // + { + Type::AnyAttributeSet s (t.getDomDocument ()); + Type::AnyAttributeIterator i (s.begin ()); + Type::AnyAttributeConstIterator ci (s.begin ()); + + if (t.getAnyAttribute () != s) + return 1; + + t.setAnyAttribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + parseRoot (is, xml_schema::Flags::dont_validate); + } + + { + ostringstream os; + xml_schema::NamespaceInfomap m; + m["t"].name = "test"; + + serializeRoot (os, "foo", m); + } + } + catch (xml_schema::Exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/tests/cxx/tree/naming/java/makefile b/tests/cxx/tree/naming/java/makefile new file mode 100644 index 0000000..d9258c7 --- /dev/null +++ b/tests/cxx/tree/naming/java/makefile @@ -0,0 +1,87 @@ +# file : tests/cxx/tree/naming/java/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--type-naming java \ +--function-naming java \ +--generate-ostream \ +--generate-serialization \ +--generate-comparison \ +--generate-wildcard + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/naming/java/test.xsd b/tests/cxx/tree/naming/java/test.xsd new file mode 100644 index 0000000..f525534 --- /dev/null +++ b/tests/cxx/tree/naming/java/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/naming/knr/driver.cxx b/tests/cxx/tree/naming/knr/driver.cxx new file mode 100644 index 0000000..5db744b --- /dev/null +++ b/tests/cxx/tree/naming/knr/driver.cxx @@ -0,0 +1,145 @@ +// file : tests/cxx/tree/naming/knr/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test K&R naming style. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + xercesc::XMLPlatformUtils::Initialize (); + + try + { + // Enum 'value' type. + // + { + gender::value v; + v = gender::female; + } + + // Anonymous type. + // + { + foo f ("a", "b"); + + if (f.a () != "a" || f.b () != "b") + return 1; + } + + // Type name and accessors/modifiers. + // + { + type t ("bar"); + + // foo + // + { + type::foo_type* p = 0; + type::foo_optional o; + + if (t.foo ().present ()) + return 1; + + t.foo (o); + } + + // bar + // + { + type::bar_type* p = 0; + + if (t.bar () != "bar") + return 1; + + t.bar ("barbar"); + } + + // baz + // + { + type::baz_type* p = 0; + type::baz_sequence s; + type::baz_iterator i (s.begin ()); + type::baz_const_iterator ci (s.begin ()); + + if (t.baz () != s) + return 1; + + t.baz (s); + } + + // any + // + { + type::any_sequence s (t.dom_document ()); + type::any_iterator i (s.begin ()); + type::any_const_iterator ci (s.begin ()); + + if (t.any () != s) + return 1; + + t.any (s); + } + + // foo + // + { + type::fox_type x = type::fox_default_value (); + + if (t.fox () != x) + return 1; + + t.fox ("fox"); + } + + // any_attribute + // + { + type::any_attribute_set s (t.dom_document ()); + type::any_attribute_iterator i (s.begin ()); + type::any_attribute_const_iterator ci (s.begin ()); + + if (t.any_attribute () != s) + return 1; + + t.any_attribute (s); + } + } + + // Parsing/serialization functions. + // + { + istringstream is ("foo"); + root (is, xml_schema::flags::dont_validate); + } + + { + ostringstream os; + xml_schema::namespace_infomap m; + m["t"].name = "test"; + + root (os, "foo", m); + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + xercesc::XMLPlatformUtils::Terminate (); +} diff --git a/tests/cxx/tree/naming/knr/makefile b/tests/cxx/tree/naming/knr/makefile new file mode 100644 index 0000000..3b92d37 --- /dev/null +++ b/tests/cxx/tree/naming/knr/makefile @@ -0,0 +1,87 @@ +# file : tests/cxx/tree/naming/knr/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := \ +--type-naming knr \ +--function-naming knr \ +--generate-ostream \ +--generate-serialization \ +--generate-comparison \ +--generate-wildcard + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/naming/knr/test.xsd b/tests/cxx/tree/naming/knr/test.xsd new file mode 100644 index 0000000..4361544 --- /dev/null +++ b/tests/cxx/tree/naming/knr/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/naming/makefile b/tests/cxx/tree/naming/makefile new file mode 100644 index 0000000..8a70665 --- /dev/null +++ b/tests/cxx/tree/naming/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/naming/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := camel java knr + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/polymorphism/comparison/driver.cxx b/tests/cxx/tree/polymorphism/comparison/driver.cxx new file mode 100644 index 0000000..02fe4f7 --- /dev/null +++ b/tests/cxx/tree/polymorphism/comparison/driver.cxx @@ -0,0 +1,75 @@ +// file : tests/cxx/tree/polymorphism/comparison/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test comparison of polymorphic object models. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + // Equals. + // + { + derived1 d ("a", 1); + d.b ("b"); + type r1 (d); + + assert (*r == r1); + } + + // Values are not equal. + // + { + derived1 d ("a", 1); + d.b ("c"); + type r1 (d); + + assert (*r != r1); + } + + // Values are not equal. + // + { + derived1 d ("a", 2); + d.b ("b"); + type r1 (d); + + assert (*r != r1); + } + + // Different types. + // + { + derived2 d ("a", 1); + d.c ().push_back ("c"); + type r1 (d); + + assert (*r != r1); + } + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/polymorphism/comparison/makefile b/tests/cxx/tree/polymorphism/comparison/makefile new file mode 100644 index 0000000..1568b9c --- /dev/null +++ b/tests/cxx/tree/polymorphism/comparison/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/polymorphism/comparison/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-polymorphic \ +--generate-comparison + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml + $(call message,test $$1,$$1 $(src_base)/test.xml,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/polymorphism/comparison/test.xml b/tests/cxx/tree/polymorphism/comparison/test.xml new file mode 100644 index 0000000..0b8c125 --- /dev/null +++ b/tests/cxx/tree/polymorphism/comparison/test.xml @@ -0,0 +1,7 @@ + + + a1b + + diff --git a/tests/cxx/tree/polymorphism/comparison/test.xsd b/tests/cxx/tree/polymorphism/comparison/test.xsd new file mode 100644 index 0000000..18532f2 --- /dev/null +++ b/tests/cxx/tree/polymorphism/comparison/test.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/polymorphism/makefile b/tests/cxx/tree/polymorphism/makefile new file mode 100644 index 0000000..b9d8bd6 --- /dev/null +++ b/tests/cxx/tree/polymorphism/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/polymorphism/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := comparison ostream same-type + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/polymorphism/ostream/driver.cxx b/tests/cxx/tree/polymorphism/ostream/driver.cxx new file mode 100644 index 0000000..c483d6f --- /dev/null +++ b/tests/cxx/tree/polymorphism/ostream/driver.cxx @@ -0,0 +1,36 @@ +// file : tests/cxx/tree/polymorphism/ostream/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test printing of polymorphic object models. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/polymorphism/ostream/makefile b/tests/cxx/tree/polymorphism/ostream/makefile new file mode 100644 index 0000000..2631035 --- /dev/null +++ b/tests/cxx/tree/polymorphism/ostream/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/polymorphism/ostream/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-polymorphic \ +--generate-ostream + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/polymorphism/ostream/output b/tests/cxx/tree/polymorphism/ostream/output new file mode 100644 index 0000000..bf0e814 --- /dev/null +++ b/tests/cxx/tree/polymorphism/ostream/output @@ -0,0 +1,13 @@ + +base: +a: a +fund: 1 +base: +a: a +fund: 1 +b: b +base: +a: a +fund: 1 +c: c1 +c: c2 diff --git a/tests/cxx/tree/polymorphism/ostream/test.xml b/tests/cxx/tree/polymorphism/ostream/test.xml new file mode 100644 index 0000000..157e15c --- /dev/null +++ b/tests/cxx/tree/polymorphism/ostream/test.xml @@ -0,0 +1,9 @@ + + + a1 + a1b + a1c1c2 + + diff --git a/tests/cxx/tree/polymorphism/ostream/test.xsd b/tests/cxx/tree/polymorphism/ostream/test.xsd new file mode 100644 index 0000000..cc1f7a8 --- /dev/null +++ b/tests/cxx/tree/polymorphism/ostream/test.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/polymorphism/same-type/driver.cxx b/tests/cxx/tree/polymorphism/same-type/driver.cxx new file mode 100644 index 0000000..f3556a5 --- /dev/null +++ b/tests/cxx/tree/polymorphism/same-type/driver.cxx @@ -0,0 +1,37 @@ +// file : tests/cxx/tree/polymorphism/same-type/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test substitution group and xsi:type that don't change the type. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/polymorphism/same-type/makefile b/tests/cxx/tree/polymorphism/same-type/makefile new file mode 100644 index 0000000..d255131 --- /dev/null +++ b/tests/cxx/tree/polymorphism/same-type/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/polymorphism/same-type/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-ostream \ +--generate-polymorphic --root-element root + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/polymorphism/same-type/output b/tests/cxx/tree/polymorphism/same-type/output new file mode 100644 index 0000000..04b5cbf --- /dev/null +++ b/tests/cxx/tree/polymorphism/same-type/output @@ -0,0 +1,9 @@ + +base: +a: a1 +base: +a: a2 +base: +a: a3 +base: +a: a4 diff --git a/tests/cxx/tree/polymorphism/same-type/test.xml b/tests/cxx/tree/polymorphism/same-type/test.xml new file mode 100644 index 0000000..f8b6d1e --- /dev/null +++ b/tests/cxx/tree/polymorphism/same-type/test.xml @@ -0,0 +1,10 @@ + + + a1 + a2 + a3 + a4 + + diff --git a/tests/cxx/tree/polymorphism/same-type/test.xsd b/tests/cxx/tree/polymorphism/same-type/test.xsd new file mode 100644 index 0000000..a4157d3 --- /dev/null +++ b/tests/cxx/tree/polymorphism/same-type/test.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/prefix/bar.xsd b/tests/cxx/tree/prefix/bar.xsd new file mode 100644 index 0000000..4e20902 --- /dev/null +++ b/tests/cxx/tree/prefix/bar.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/prefix/driver.cxx b/tests/cxx/tree/prefix/driver.cxx new file mode 100644 index 0000000..7155345 --- /dev/null +++ b/tests/cxx/tree/prefix/driver.cxx @@ -0,0 +1,36 @@ +// file : tests/cxx/tree/prefix/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test automatic prefix assignment. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + root (std::cout, *r); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/prefix/foo.xsd b/tests/cxx/tree/prefix/foo.xsd new file mode 100644 index 0000000..97a35cf --- /dev/null +++ b/tests/cxx/tree/prefix/foo.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/prefix/makefile b/tests/cxx/tree/prefix/makefile new file mode 100644 index 0000000..858925a --- /dev/null +++ b/tests/cxx/tree/prefix/makefile @@ -0,0 +1,76 @@ +# file : tests/cxx/tree/prefix/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +xsd := test.xsd foo.xsd bar.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) + +gen := $(addprefix $(out_base)/,$(xsd:.xsd=.hxx) $(xsd:.xsd=.ixx) $(xsd:.xsd=.cxx)) + +$(gen): xsd := $(out_root)/xsd/xsd +$(gen): xsd_options := --generate-serialization --generate-polymorphic \ +--root-element root +$(gen): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/prefix/output b/tests/cxx/tree/prefix/output new file mode 100644 index 0000000..4f40f49 --- /dev/null +++ b/tests/cxx/tree/prefix/output @@ -0,0 +1,22 @@ + + + + + 123 + + + + + 1 + 2 + + + + + + 1 + 2 + + + + diff --git a/tests/cxx/tree/prefix/test.xml b/tests/cxx/tree/prefix/test.xml new file mode 100644 index 0000000..b6d0dd6 --- /dev/null +++ b/tests/cxx/tree/prefix/test.xml @@ -0,0 +1,19 @@ + + + + 123 + + + + 12 + + + + 12 + + + diff --git a/tests/cxx/tree/prefix/test.xsd b/tests/cxx/tree/prefix/test.xsd new file mode 100644 index 0000000..421fdc0 --- /dev/null +++ b/tests/cxx/tree/prefix/test.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/test-template/driver.cxx b/tests/cxx/tree/test-template/driver.cxx new file mode 100644 index 0000000..55b7a76 --- /dev/null +++ b/tests/cxx/tree/test-template/driver.cxx @@ -0,0 +1,37 @@ +// file : tests/cxx/tree/test-template/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Insert test description here. +// + +#include // std::auto_ptr +#include + +#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 r (root (argv[1])); + + cout << *r << endl; + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } +} diff --git a/tests/cxx/tree/test-template/makefile b/tests/cxx/tree/test-template/makefile new file mode 100644 index 0000000..7dceb17 --- /dev/null +++ b/tests/cxx/tree/test-template/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/test-template/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-ostream + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/test-template/output b/tests/cxx/tree/test-template/output new file mode 100644 index 0000000..2a50681 --- /dev/null +++ b/tests/cxx/tree/test-template/output @@ -0,0 +1,2 @@ + +a: a diff --git a/tests/cxx/tree/test-template/test.xml b/tests/cxx/tree/test-template/test.xml new file mode 100644 index 0000000..624a80c --- /dev/null +++ b/tests/cxx/tree/test-template/test.xml @@ -0,0 +1,7 @@ + + + a + + diff --git a/tests/cxx/tree/test-template/test.xsd b/tests/cxx/tree/test-template/test.xsd new file mode 100644 index 0000000..07bebc7 --- /dev/null +++ b/tests/cxx/tree/test-template/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/cxx/tree/types-only/driver.cxx b/tests/cxx/tree/types-only/driver.cxx new file mode 100644 index 0000000..1d819f1 --- /dev/null +++ b/tests/cxx/tree/types-only/driver.cxx @@ -0,0 +1,33 @@ +// file : tests/cxx/tree/types-only/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test that code generated without parsing and serialization functions +// still compiles. +// + +#include // std::auto_ptr +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + color_enum red (color_enum::red); + red_blue_enum blue (red_blue_enum::blue); + + long_string_union num ("123"); + + string_list list; + list.push_back ("Hello"); + list.push_back ("World"); + + complex_type t ("Hello, World!", "foo", color_enum::red); + + anon a ("Hello, World!"); +} diff --git a/tests/cxx/tree/types-only/makefile b/tests/cxx/tree/types-only/makefile new file mode 100644 index 0000000..5d55225 --- /dev/null +++ b/tests/cxx/tree/types-only/makefile @@ -0,0 +1,81 @@ +# file : tests/cxx/tree/types-only/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --suppress-parsing + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/types-only/test.xsd b/tests/cxx/tree/types-only/test.xsd new file mode 100644 index 0000000..d6ae44d --- /dev/null +++ b/tests/cxx/tree/types-only/test.xsd @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/union/ctor/driver.cxx b/tests/cxx/tree/union/ctor/driver.cxx new file mode 100644 index 0000000..965c98c --- /dev/null +++ b/tests/cxx/tree/union/ctor/driver.cxx @@ -0,0 +1,32 @@ +// file : tests/cxx/tree/union/ctor/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test union constructors. +// +#include + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor(const std::string&) + // + { + string const s ("123"); + int_string_union u (s); + type t (s); + } + + // Test ctor(const char*). + // + { + int_string_union u ("123"); + type t ("123"); + } +} diff --git a/tests/cxx/tree/union/ctor/makefile b/tests/cxx/tree/union/ctor/makefile new file mode 100644 index 0000000..13f1ae8 --- /dev/null +++ b/tests/cxx/tree/union/ctor/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/union/ctor/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \ +--generate-from-base-ctor --generate-doxygen + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/union/ctor/test.xsd b/tests/cxx/tree/union/ctor/test.xsd new file mode 100644 index 0000000..9601093 --- /dev/null +++ b/tests/cxx/tree/union/ctor/test.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/cxx/tree/union/makefile b/tests/cxx/tree/union/makefile new file mode 100644 index 0000000..4a2d045 --- /dev/null +++ b/tests/cxx/tree/union/makefile @@ -0,0 +1,20 @@ +# file : tests/cxx/tree/union/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make + +tests := ctor + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(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/tests/cxx/tree/wildcard/driver.cxx b/tests/cxx/tree/wildcard/driver.cxx new file mode 100644 index 0000000..5f46e1b --- /dev/null +++ b/tests/cxx/tree/wildcard/driver.cxx @@ -0,0 +1,202 @@ +// file : tests/cxx/tree/wildcard/driver.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test wildcard (any & anyAttribute) mapping. +// + +#include // std::auto_ptr +#include +#include + +#include + +#include "test.hxx" + +using namespace std; +using namespace test; +using namespace xercesc; + +namespace xml = xsd::cxx::xml; + +void +print (type& t) +{ + if (t.att ()) + cout << *t.att () << endl; + + type::any_attribute_set& as (t.any_attribute ()); + + for (type::any_attribute_iterator i (as.begin ()); i != as.end (); ++i) + { + cout << xml::transcode (i->getTextContent ()) << endl; + } + + cout << xml::transcode (t.any ().getTextContent ()) << endl + << t.foo () << endl; + + if (t.any1 ()) + cout << xml::transcode (t.any1 ()->getTextContent ()) << endl; + + cout << t.bar () << endl; + + type::any2_sequence& es (t.any2 ()); + + for (type::any2_iterator i (es.begin ()); i != es.end (); ++i) + { + cout << xml::transcode (i->getTextContent ()) << endl; + } + + cout << endl; +} + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + XMLPlatformUtils::Initialize (); + + try + { + // Test accessors/modifiers for various cardinalities. + // + type t; + + DOMDocument& doc (t.dom_document ()); + + // one + // + { + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + t.any (*e); + e->release (); + assert (xml::transcode (t.any ().getTagName ()) == "a"); + + t.any (doc.createElement (xml::string ("b").c_str ())); + assert (xml::transcode (t.any ().getTagName ()) == "b"); + } + + // optional + // + { + assert (!t.any1 ().present ()); + + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + t.any1 (*e); + e->release (); + assert (t.any1 ().present ()); + assert (xml::transcode (t.any1 ().get ().getTagName ()) == "a"); + + t.any1 (doc.createElement (xml::string ("b").c_str ())); + assert (xml::transcode (t.any1 ()->getTagName ()) == "b"); + + type::any1_optional c ( + doc.createElement (xml::string ("c").c_str ()), doc); + t.any1 (c); + assert (xml::transcode (t.any1 ()->getTagName ()) == "c"); + } + + + // sequence + // + { + type::any2_sequence& s (t.any2 ()); + + DOMElement* e (doc.createElement (xml::string ("a").c_str ())); + s.push_back (*e); + e->release (); + s.push_back (doc.createElement (xml::string ("b").c_str ())); + assert (s.size () == 2); + + for (type::any2_iterator i (s.begin ()); i != s.end (); ++i) + { + if (i == s.begin ()) + assert (xml::transcode (i->getTagName ()) == "a"); + else + assert (xml::transcode ((*i).getTagName ()) == "b"); + } + + // copy c-tor + type::any2_sequence cs (s, doc); + assert (cs.size () == 2); + assert (xml::transcode (cs[0].getTagName ()) == "a"); + assert (xml::transcode (cs[1].getTagName ()) == "b"); + + // assignment + t.any2 (cs); + assert (s.size () == 2); + assert (xml::transcode (s[0].getTagName ()) == "a"); + assert (xml::transcode (s[1].getTagName ()) == "b"); + } + + // anyAttribute + // + { + type::any_attribute_set& s (t.any_attribute ()); + + DOMAttr* a (doc.createAttribute (xml::string ("a").c_str ())); + s.insert (*a); + a->release (); + s.insert (doc.createAttribute (xml::string ("b").c_str ())); + assert (s.size () == 2); + + assert (s.find ("a") != s.end ()); + assert (s.find ("b") != s.end ()); + + for (type::any_attribute_iterator i (s.begin ()); i != s.end (); ++i) + { + assert (xml::transcode (i->getName ()) == "a" || + xml::transcode ((*i).getName ()) == "b"); + } + + // copy c-tor + type::any_attribute_set cs (s, doc); + assert (cs.size () == 2); + assert (cs.count ("a")); + assert (cs.count ("b")); + + // assignment + t.any_attribute (cs); + assert (s.size () == 2); + assert (s.count ("a")); + assert (s.count ("b")); + } + + // Test parsing + // + auto_ptr r (root (argv[1])); + print (*r); + + // Test serialization. + // + xml_schema::namespace_infomap map; + + map["t"].name = "test"; + map["t"].schema = "test.xsd"; + map["o"].name = "other"; + + stringstream iostr; + root (iostr, *r, map); + + // cout << iostr.str () << endl + // << endl; + + auto_ptr copy (root (iostr, argv[1])); + assert (*copy == *r); + + print (*copy); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + + XMLPlatformUtils::Terminate (); +} diff --git a/tests/cxx/tree/wildcard/makefile b/tests/cxx/tree/wildcard/makefile new file mode 100644 index 0000000..6d5eb83 --- /dev/null +++ b/tests/cxx/tree/wildcard/makefile @@ -0,0 +1,83 @@ +# file : tests/cxx/tree/wildcard/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2006-2009 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) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-wildcard \ +--generate-default-ctor --generate-from-base-ctor \ +--generate-serialization --generate-comparison + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) $(src_base)/test.xml $(src_base)/output + $(call message,test $$1,$$1 $(src_base)/test.xml | diff -u $(src_base)/output -,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# 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/tests/cxx/tree/wildcard/output b/tests/cxx/tree/wildcard/output new file mode 100644 index 0000000..b23b488 --- /dev/null +++ b/tests/cxx/tree/wildcard/output @@ -0,0 +1,24 @@ +att +any +o:any +t:any +o:one +foo +t:bar +bar +o:one1 +o:one2 +o:one3 + +att +any +o:any +t:any +o:one +foo +t:bar +bar +o:one1 +o:one2 +o:one3 + diff --git a/tests/cxx/tree/wildcard/test.xml b/tests/cxx/tree/wildcard/test.xml new file mode 100644 index 0000000..b0c3267 --- /dev/null +++ b/tests/cxx/tree/wildcard/test.xml @@ -0,0 +1,19 @@ + + + o:one + foo + t:bar + bar + o:one1 + o:one2 + o:one3 + + diff --git a/tests/cxx/tree/wildcard/test.xsd b/tests/cxx/tree/wildcard/test.xsd new file mode 100644 index 0000000..6c7b308 --- /dev/null +++ b/tests/cxx/tree/wildcard/test.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/failed/test-00.xsd b/tests/failed/test-00.xsd new file mode 100644 index 0000000..5223f82 --- /dev/null +++ b/tests/failed/test-00.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/tests/makefile b/tests/makefile new file mode 100644 index 0000000..f966c5c --- /dev/null +++ b/tests/makefile @@ -0,0 +1,18 @@ +# file : tests/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +default := $(out_base)/ +test := $(out_base)/.test +clean := $(out_base)/.clean + +.PHONY: $(default) $(test) $(clean) + +$(default): $(out_base)/cxx/ +$(test): $(out_base)/cxx/.test +$(clean): $(out_base)/cxx/.clean + +$(call import,$(src_base)/cxx/makefile) diff --git a/tests/morphing/anonymous/attribute-group/test.xsd b/tests/morphing/anonymous/attribute-group/test.xsd new file mode 100644 index 0000000..657be8a --- /dev/null +++ b/tests/morphing/anonymous/attribute-group/test.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/morphing/anonymous/cyclic-inclusion/includee.xsd b/tests/morphing/anonymous/cyclic-inclusion/includee.xsd new file mode 100644 index 0000000..51f7916 --- /dev/null +++ b/tests/morphing/anonymous/cyclic-inclusion/includee.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/tests/morphing/anonymous/cyclic-inclusion/includer.xsd b/tests/morphing/anonymous/cyclic-inclusion/includer.xsd new file mode 100644 index 0000000..54e6b69 --- /dev/null +++ b/tests/morphing/anonymous/cyclic-inclusion/includer.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/tests/morphing/anonymous/group/test.xsd b/tests/morphing/anonymous/group/test.xsd new file mode 100644 index 0000000..73e07af --- /dev/null +++ b/tests/morphing/anonymous/group/test.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/morphing/anonymous/test-000.xsd b/tests/morphing/anonymous/test-000.xsd new file mode 100644 index 0000000..ce930d8 --- /dev/null +++ b/tests/morphing/anonymous/test-000.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/morphing/anonymous/unstable/includee-1.xsd b/tests/morphing/anonymous/unstable/includee-1.xsd new file mode 100644 index 0000000..916816f --- /dev/null +++ b/tests/morphing/anonymous/unstable/includee-1.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/tests/morphing/anonymous/unstable/includee-2.xsd b/tests/morphing/anonymous/unstable/includee-2.xsd new file mode 100644 index 0000000..eb8222c --- /dev/null +++ b/tests/morphing/anonymous/unstable/includee-2.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tests/morphing/anonymous/unstable/includer.xsd b/tests/morphing/anonymous/unstable/includer.xsd new file mode 100644 index 0000000..4593b5f --- /dev/null +++ b/tests/morphing/anonymous/unstable/includer.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/tests/processing/inheritance/test-000.xsd b/tests/processing/inheritance/test-000.xsd new file mode 100644 index 0000000..ef1ef71 --- /dev/null +++ b/tests/processing/inheritance/test-000.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/processing/inheritance/test-001.xsd b/tests/processing/inheritance/test-001.xsd new file mode 100644 index 0000000..5afc997 --- /dev/null +++ b/tests/processing/inheritance/test-001.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/anonymous/test.xsd b/tests/schema/anonymous/test.xsd new file mode 100644 index 0000000..cba3300 --- /dev/null +++ b/tests/schema/anonymous/test.xsd @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/any-attribute/test.xsd b/tests/schema/any-attribute/test.xsd new file mode 100644 index 0000000..55419c4 --- /dev/null +++ b/tests/schema/any-attribute/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/any-type/test.xsd b/tests/schema/any-type/test.xsd new file mode 100644 index 0000000..9e3ff79 --- /dev/null +++ b/tests/schema/any-type/test.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/any/fail.xsd b/tests/schema/any/fail.xsd new file mode 100644 index 0000000..2eb9513 --- /dev/null +++ b/tests/schema/any/fail.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/tests/schema/any/test.xsd b/tests/schema/any/test.xsd new file mode 100644 index 0000000..ff896fd --- /dev/null +++ b/tests/schema/any/test.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/tests/schema/attribute-group/global.xsd b/tests/schema/attribute-group/global.xsd new file mode 100644 index 0000000..6ee0539 --- /dev/null +++ b/tests/schema/attribute-group/global.xsd @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/attribute/global.xsd b/tests/schema/attribute/global.xsd new file mode 100644 index 0000000..e2dcc93 --- /dev/null +++ b/tests/schema/attribute/global.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/schema/attribute/local.xsd b/tests/schema/attribute/local.xsd new file mode 100644 index 0000000..7a7a480 --- /dev/null +++ b/tests/schema/attribute/local.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/attribute/ref.xsd b/tests/schema/attribute/ref.xsd new file mode 100644 index 0000000..f6c3c10 --- /dev/null +++ b/tests/schema/attribute/ref.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/cardinality/test.xsd b/tests/schema/cardinality/test.xsd new file mode 100644 index 0000000..b27f923 --- /dev/null +++ b/tests/schema/cardinality/test.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/chameleon/includer.xsd b/tests/schema/chameleon/includer.xsd new file mode 100644 index 0000000..c93ea18 --- /dev/null +++ b/tests/schema/chameleon/includer.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/tests/schema/chameleon/schemas/includee.xsd b/tests/schema/chameleon/schemas/includee.xsd new file mode 100644 index 0000000..d89b9c4 --- /dev/null +++ b/tests/schema/chameleon/schemas/includee.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/tests/schema/enumeration/test.xsd b/tests/schema/enumeration/test.xsd new file mode 100644 index 0000000..b8253d9 --- /dev/null +++ b/tests/schema/enumeration/test.xsd @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/forward/test.xsd b/tests/schema/forward/test.xsd new file mode 100644 index 0000000..c7cc24e --- /dev/null +++ b/tests/schema/forward/test.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/group/global.xsd b/tests/schema/group/global.xsd new file mode 100644 index 0000000..27ccadf --- /dev/null +++ b/tests/schema/group/global.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/group/test.xsd b/tests/schema/group/test.xsd new file mode 100644 index 0000000..7527cbb --- /dev/null +++ b/tests/schema/group/test.xsd @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/import/importer.xsd b/tests/schema/import/importer.xsd new file mode 100644 index 0000000..82fc33c --- /dev/null +++ b/tests/schema/import/importer.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/tests/schema/import/schemas/importee.xsd b/tests/schema/import/schemas/importee.xsd new file mode 100644 index 0000000..9b03315 --- /dev/null +++ b/tests/schema/import/schemas/importee.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/tests/schema/include/includer.xsd b/tests/schema/include/includer.xsd new file mode 100644 index 0000000..c93ea18 --- /dev/null +++ b/tests/schema/include/includer.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/tests/schema/include/schemas/includee.xsd b/tests/schema/include/schemas/includee.xsd new file mode 100644 index 0000000..0a928f5 --- /dev/null +++ b/tests/schema/include/schemas/includee.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tests/schema/inheritance/cycle.xsd b/tests/schema/inheritance/cycle.xsd new file mode 100644 index 0000000..c705311 --- /dev/null +++ b/tests/schema/inheritance/cycle.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/inheritance/sourced-forward/includee.xsd b/tests/schema/inheritance/sourced-forward/includee.xsd new file mode 100644 index 0000000..531027d --- /dev/null +++ b/tests/schema/inheritance/sourced-forward/includee.xsd @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/tests/schema/inheritance/sourced-forward/includer.xsd b/tests/schema/inheritance/sourced-forward/includer.xsd new file mode 100644 index 0000000..7d18efc --- /dev/null +++ b/tests/schema/inheritance/sourced-forward/includer.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tests/schema/list/anonymous/test.xsd b/tests/schema/list/anonymous/test.xsd new file mode 100644 index 0000000..7db39ba --- /dev/null +++ b/tests/schema/list/anonymous/test.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/tests/schema/list/any-simple-type/test.xsd b/tests/schema/list/any-simple-type/test.xsd new file mode 100644 index 0000000..29fe95c --- /dev/null +++ b/tests/schema/list/any-simple-type/test.xsd @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/tests/schema/list/driver.cxx b/tests/schema/list/driver.cxx new file mode 100644 index 0000000..7bd46e9 --- /dev/null +++ b/tests/schema/list/driver.cxx @@ -0,0 +1,13 @@ +#include "test.hxx" + +typedef xmlns::test::IntList IntListImpl; +typedef xmlns::test::IntList IntListVoidImpl; +typedef xmlns::test::IntComplex IntComplexImpl; + +int +main () +{ + IntListImpl int_list_impl; + IntListVoidImpl int_list_void_impl; + IntComplexImpl int_complex_impl; +} diff --git a/tests/schema/list/test.xsd b/tests/schema/list/test.xsd new file mode 100644 index 0000000..e16a58d --- /dev/null +++ b/tests/schema/list/test.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/no-namespace/test.xsd b/tests/schema/no-namespace/test.xsd new file mode 100644 index 0000000..b426e8a --- /dev/null +++ b/tests/schema/no-namespace/test.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/tests/schema/recursive/test.xsd b/tests/schema/recursive/test.xsd new file mode 100644 index 0000000..6efc7d2 --- /dev/null +++ b/tests/schema/recursive/test.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/ref-type/idref.xsd b/tests/schema/ref-type/idref.xsd new file mode 100644 index 0000000..49ebe40 --- /dev/null +++ b/tests/schema/ref-type/idref.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/ref-type/idrefs.xsd b/tests/schema/ref-type/idrefs.xsd new file mode 100644 index 0000000..b68ed03 --- /dev/null +++ b/tests/schema/ref-type/idrefs.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/ref-type/invalid-0.xsd b/tests/schema/ref-type/invalid-0.xsd new file mode 100644 index 0000000..7ce82ed --- /dev/null +++ b/tests/schema/ref-type/invalid-0.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/tests/schema/ref-type/invalid-1.xsd b/tests/schema/ref-type/invalid-1.xsd new file mode 100644 index 0000000..d989065 --- /dev/null +++ b/tests/schema/ref-type/invalid-1.xsd @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/tests/schema/restriction/test.xsd b/tests/schema/restriction/test.xsd new file mode 100644 index 0000000..331ba78 --- /dev/null +++ b/tests/schema/restriction/test.xsd @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/schema/union/test.xsd b/tests/schema/union/test.xsd new file mode 100644 index 0000000..706f6f2 --- /dev/null +++ b/tests/schema/union/test.xsd @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1