diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-10-16 17:49:34 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-10-16 17:49:34 +0200 |
commit | c8c60d865a62ff8450b9c907fb1c4cab727130c5 (patch) | |
tree | f90e4144ac6a34044b24c34686734e13290c388b /tests | |
parent | b83ab123bb6ba364e22e3665ffafb44686592de6 (diff) |
Rework to use the uniform test interface
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cxx/parser/reset/driver.cxx | 72 | ||||
-rw-r--r-- | tests/cxx/parser/reset/makefile | 19 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-000.std (renamed from tests/cxx/parser/reset/test.std) | 2 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-000.xml (renamed from tests/cxx/parser/reset/pass.xml) | 0 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-001.std | 1 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-001.xml (renamed from tests/cxx/parser/reset/fail-xml.xml) | 0 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-002.std | 1 | ||||
-rw-r--r-- | tests/cxx/parser/reset/test-002.xml (renamed from tests/cxx/parser/reset/fail-schema.xml) | 0 |
8 files changed, 71 insertions, 24 deletions
diff --git a/tests/cxx/parser/reset/driver.cxx b/tests/cxx/parser/reset/driver.cxx index 5701df5..149c3da 100644 --- a/tests/cxx/parser/reset/driver.cxx +++ b/tests/cxx/parser/reset/driver.cxx @@ -7,8 +7,10 @@ // #include <assert.h> +#include <string.h> // strlen #include <string> +#include <sstream> #include <iostream> #include "test-pskel.hxx" @@ -16,6 +18,10 @@ using namespace std; using namespace test; +// Same as test-000.xml +// +const char* pass = "<t:root xmlns:t='test'><a><b>1</b></a></t:root>"; + bool fail = true; struct error {}; @@ -156,20 +162,46 @@ private: int main (int argc, char* argv[]) { - if (argc != 4) + if (argc != 2) { - cerr << "usage: " << argv[0] << " pass.xml fail-xml.xml fail-schema.xml" - << endl; + cerr << "usage: " << argv[0] << " test.xml" << endl; return 1; } - const char* pass = argv[1]; - const char* fail_xml = argv[2]; - const char* fail_schema = argv[3]; + // Set the range depending on which test we are running. + // + unsigned long start, end; + + switch (argv[1][strlen (argv[1]) - 5]) + { + case '0': + { + start = 0; + end = 6; + break; + } + case '1': + { + start = 6; + end = 7; + break; + } + case '2': + { + start = 7; + end = 8; + break; + } + default: + { + cerr << "unsupported test" << endl; + return 1; + } + } try { - for (unsigned long i (0); i < 8; ++i) + for (unsigned long i = start; i < end; ++i) { #ifndef XSDE_PARSER_VALIDATION if (i == 7) @@ -199,17 +231,23 @@ main (int argc, char* argv[]) { case 6: { - doc_p.parse (fail_xml); + // Fail XML. + // + doc_p.parse (argv[1]); break; } case 7: { - doc_p.parse (fail_schema); + // Fail Schema. + // + doc_p.parse (argv[1]); break; } default: { - doc_p.parse (pass); + // Pass. + // + doc_p.parse (argv[1]); break; } } @@ -227,8 +265,10 @@ main (int argc, char* argv[]) fail = false; doc_p.reset (); + istringstream is (pass); + type_p.pre (); - doc_p.parse (pass); + doc_p.parse (is); type_p.post_type (); #else do @@ -244,17 +284,17 @@ main (int argc, char* argv[]) { case 6: { - doc_p.parse (fail_xml); + doc_p.parse (argv[1]); break; } case 7: { - doc_p.parse (fail_schema); + doc_p.parse (argv[1]); break; } default: { - doc_p.parse (pass); + doc_p.parse (argv[1]); break; } } @@ -274,10 +314,12 @@ main (int argc, char* argv[]) fail = false; doc_p.reset (); + istringstream is (pass); + type_p.pre (); assert (!type_p._error ()); - doc_p.parse (pass); + doc_p.parse (is); assert (!doc_p._error ()); type_p.post_type (); diff --git a/tests/cxx/parser/reset/makefile b/tests/cxx/parser/reset/makefile index c1d683c..a89ff92 100644 --- a/tests/cxx/parser/reset/makefile +++ b/tests/cxx/parser/reset/makefile @@ -8,6 +8,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make xsd := test.xsd cxx := driver.cxx +tests := 000 001 002 + obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o)) dep := $(obj:.o=.o.d) @@ -38,14 +40,17 @@ $(call include-dep,$(dep)) $(out_base)/: $(driver) -# Test. +# Test. 000 - pass, 001 - fail xml, 002 - fail schema. # -$(test): driver := $(driver) -$(test): $(driver) $(src_base)/pass.xml $(src_base)/fail-xml.xml \ - $(src_base)/fail-schema.xml $(src_base)/test.std - $(call message,test $$1,$$1 $(src_base)/pass.xml \ -$(src_base)/fail-xml.xml $(src_base)/fail-schema.xml \ -| diff -u $(src_base)/test.std -,$(driver)) +test_targets := $(addprefix $(out_base)/.test-,$(tests)) + +$(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. # diff --git a/tests/cxx/parser/reset/test.std b/tests/cxx/parser/reset/test-000.std index 0e6cb1e..3bec760 100644 --- a/tests/cxx/parser/reset/test.std +++ b/tests/cxx/parser/reset/test-000.std @@ -4,5 +4,3 @@ 3: 1 4: 1 5: 1 -6: 1 -7: 1 diff --git a/tests/cxx/parser/reset/pass.xml b/tests/cxx/parser/reset/test-000.xml index 956ec2a..956ec2a 100644 --- a/tests/cxx/parser/reset/pass.xml +++ b/tests/cxx/parser/reset/test-000.xml diff --git a/tests/cxx/parser/reset/test-001.std b/tests/cxx/parser/reset/test-001.std new file mode 100644 index 0000000..ec1fd5e --- /dev/null +++ b/tests/cxx/parser/reset/test-001.std @@ -0,0 +1 @@ +6: 1 diff --git a/tests/cxx/parser/reset/fail-xml.xml b/tests/cxx/parser/reset/test-001.xml index b2aacb2..b2aacb2 100644 --- a/tests/cxx/parser/reset/fail-xml.xml +++ b/tests/cxx/parser/reset/test-001.xml diff --git a/tests/cxx/parser/reset/test-002.std b/tests/cxx/parser/reset/test-002.std new file mode 100644 index 0000000..0c14e7d --- /dev/null +++ b/tests/cxx/parser/reset/test-002.std @@ -0,0 +1 @@ +7: 1 diff --git a/tests/cxx/parser/reset/fail-schema.xml b/tests/cxx/parser/reset/test-002.xml index 92c6c8b..92c6c8b 100644 --- a/tests/cxx/parser/reset/fail-schema.xml +++ b/tests/cxx/parser/reset/test-002.xml |