aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-10-16 10:43:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-10-16 10:43:59 +0200
commitb83ab123bb6ba364e22e3665ffafb44686592de6 (patch)
tree4138be9880fd17cd80aac121df94e1efe40bfbee /tests
parent4ed219d64921e14b9809fd3a535f94fbe2c01d26 (diff)
Rework the tests to conform to the uniform interface
Diffstat (limited to 'tests')
-rw-r--r--tests/cxx/parser/built-in/driver.cxx26
-rw-r--r--tests/cxx/parser/built-in/makefile22
-rw-r--r--tests/cxx/parser/built-in/test-000.std (renamed from tests/cxx/parser/built-in/test-long-000.std)0
-rw-r--r--tests/cxx/parser/built-in/test-000.xml (renamed from tests/cxx/parser/built-in/test-long-000.xml)0
-rw-r--r--tests/cxx/parser/built-in/test-001.std (renamed from tests/cxx/parser/built-in/test-long-long-000.std)0
-rw-r--r--tests/cxx/parser/built-in/test-001.xml (renamed from tests/cxx/parser/built-in/test-long-long-000.xml)0
-rw-r--r--tests/cxx/serializer/built-in/driver.cxx43
-rw-r--r--tests/cxx/serializer/built-in/makefile22
-rw-r--r--tests/cxx/serializer/built-in/test-000.std (renamed from tests/cxx/serializer/built-in/output-long)0
-rw-r--r--tests/cxx/serializer/built-in/test-001.std (renamed from tests/cxx/serializer/built-in/output-long-long)0
10 files changed, 88 insertions, 25 deletions
diff --git a/tests/cxx/parser/built-in/driver.cxx b/tests/cxx/parser/built-in/driver.cxx
index adaea5a..99c2f63 100644
--- a/tests/cxx/parser/built-in/driver.cxx
+++ b/tests/cxx/parser/built-in/driver.cxx
@@ -6,7 +6,9 @@
// Test built-in type parsing.
//
+#include <string.h> // strlen, strcmp
#include <string>
+#include <fstream>
#include <iostream>
#include "test-pskel.hxx"
@@ -542,6 +544,30 @@ main (int argc, char* argv[])
return 1;
}
+ // Ignore one of the tests depending on whether long long is available.
+ //
+ {
+ char* s = argv[1];
+ size_t n = strlen (s);
+
+ if (strcmp (s + n - 12,
+#ifdef XSDE_LONGLONG
+ "test-000.xml"
+#else
+ "test-001.xml"
+#endif
+ ) == 0)
+ {
+ s[n - 3] = 's';
+ s[n - 2] = 't';
+ s[n - 1] = 'd';
+
+ ifstream ifs (s);
+ cout << ifs.rdbuf ();
+ return 0;
+ }
+ }
+
try
{
any_type_pimpl any_type_p;
diff --git a/tests/cxx/parser/built-in/makefile b/tests/cxx/parser/built-in/makefile
index 7a30cdb..49eb681 100644
--- a/tests/cxx/parser/built-in/makefile
+++ b/tests/cxx/parser/built-in/makefile
@@ -8,6 +8,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
xsd := test.xsd
cxx := driver.cxx
+tests := 000 001
+
obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-pskel.o))
dep := $(obj:.o=.o.d)
@@ -38,17 +40,17 @@ $(call include-dep,$(dep))
$(out_base)/: $(driver)
-# Test.
+# Test. 000 - long, 001 - long long; the test driver ignores one.
#
-$(test): driver := $(driver)
-
-ifeq ($(xsde_longlong),y)
-$(test): $(driver) $(src_base)/test-long-long-000.xml $(src_base)/test-long-long-000.std
- $(call message,test $$1,$$1 $(src_base)/test-long-long-000.xml | diff -u $(src_base)/test-long-long-000.std -,$(driver))
-else
-$(test): $(driver) $(src_base)/test-long-000.xml $(src_base)/test-long-000.std
- $(call message,test $$1,$$1 $(src_base)/test-long-000.xml | diff -u $(src_base)/test-long-000.std -,$(driver))
-endif
+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/built-in/test-long-000.std b/tests/cxx/parser/built-in/test-000.std
index f3526bc..f3526bc 100644
--- a/tests/cxx/parser/built-in/test-long-000.std
+++ b/tests/cxx/parser/built-in/test-000.std
diff --git a/tests/cxx/parser/built-in/test-long-000.xml b/tests/cxx/parser/built-in/test-000.xml
index 380b0f4..380b0f4 100644
--- a/tests/cxx/parser/built-in/test-long-000.xml
+++ b/tests/cxx/parser/built-in/test-000.xml
diff --git a/tests/cxx/parser/built-in/test-long-long-000.std b/tests/cxx/parser/built-in/test-001.std
index 3b80787..3b80787 100644
--- a/tests/cxx/parser/built-in/test-long-long-000.std
+++ b/tests/cxx/parser/built-in/test-001.std
diff --git a/tests/cxx/parser/built-in/test-long-long-000.xml b/tests/cxx/parser/built-in/test-001.xml
index 8d9332a..8d9332a 100644
--- a/tests/cxx/parser/built-in/test-long-long-000.xml
+++ b/tests/cxx/parser/built-in/test-001.xml
diff --git a/tests/cxx/serializer/built-in/driver.cxx b/tests/cxx/serializer/built-in/driver.cxx
index f1d17a1..453fd29 100644
--- a/tests/cxx/serializer/built-in/driver.cxx
+++ b/tests/cxx/serializer/built-in/driver.cxx
@@ -7,7 +7,8 @@
//
#include <stdlib.h> // strtof, strtod
-#include <string.h> // memcpy
+#include <string.h> // memcpy, strlen, strcmp
+#include <fstream>
#include <iostream>
#include "test-sskel.hxx"
@@ -481,7 +482,7 @@ struct root_simpl: root_sskel
}
case 1:
{
- string_sequence* r = new string_sequence;
+ string_sequence* r = new string_sequence;
r->push_back ("one");
r->push_back ("two");
r->push_back ("three");
@@ -544,13 +545,13 @@ struct root_simpl: root_sskel
{
case 0:
{
- string_sequence* r = new string_sequence;
+ string_sequence* r = new string_sequence;
r->push_back ("one");
return r;
}
case 1:
{
- string_sequence* r = new string_sequence;
+ string_sequence* r = new string_sequence;
r->push_back ("two");
r->push_back ("three");
return r;
@@ -1190,8 +1191,38 @@ private:
};
int
-main ()
+main (int argc, char* argv[])
{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " <test-id>" << endl;
+ return 1;
+ }
+
+ // Ignore one of the tests depending on whether long long is available.
+ //
+ {
+ char* s = argv[1];
+ size_t n = strlen (s);
+
+ if (strcmp (s + n - 12,
+#ifdef XSDE_LONGLONG
+ "test-000.xml"
+#else
+ "test-001.xml"
+#endif
+ ) == 0)
+ {
+ s[n - 3] = 's';
+ s[n - 2] = 't';
+ s[n - 1] = 'd';
+
+ ifstream ifs (s);
+ cout << ifs.rdbuf ();
+ return 0;
+ }
+ }
+
any_type_simpl any_type_s;
any_simple_type_simpl any_simple_type_s;
@@ -1231,7 +1262,7 @@ main ()
#ifdef XSDE_STL
xml_schema::qname_simpl qname_s;
#else
- xml_schema::qname_simpl qname_s (true);
+ xml_schema::qname_simpl qname_s (true);
#endif
xml_schema::idrefs_simpl idrefs_s (true);
diff --git a/tests/cxx/serializer/built-in/makefile b/tests/cxx/serializer/built-in/makefile
index ba93a6d..c0f3c84 100644
--- a/tests/cxx/serializer/built-in/makefile
+++ b/tests/cxx/serializer/built-in/makefile
@@ -8,6 +8,8 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make
xsd := test.xsd
cxx := driver.cxx
+tests := 000 001
+
obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=-sskel.o))
dep := $(obj:.o=.o.d)
@@ -40,15 +42,17 @@ $(out_base)/: $(driver)
# Test.
#
-$(test): driver := $(driver)
-
-ifeq ($(xsde_longlong),y)
-$(test): $(driver) $(src_base)/output-long-long
- $(call message,test $$1,$$1 | diff -u $(src_base)/output-long-long -,$(driver))
-else
-$(test): $(driver) $(src_base)/output-long
- $(call message,test $$1,$$1 | diff -u $(src_base)/output-long -,$(driver))
-endif
+# Test. 000 - long, 001 - long long; the test driver ignores one. The
+# input files do not exist.
+#
+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-%.std
+ $(call message,test $(out_base)/$*,$(driver) $(src_base)/test-$*.xml | diff -u $(src_base)/test-$*.std -)
# Clean.
diff --git a/tests/cxx/serializer/built-in/output-long b/tests/cxx/serializer/built-in/test-000.std
index 7333c2d..7333c2d 100644
--- a/tests/cxx/serializer/built-in/output-long
+++ b/tests/cxx/serializer/built-in/test-000.std
diff --git a/tests/cxx/serializer/built-in/output-long-long b/tests/cxx/serializer/built-in/test-001.std
index b0f36cc..b0f36cc 100644
--- a/tests/cxx/serializer/built-in/output-long-long
+++ b/tests/cxx/serializer/built-in/test-001.std