diff options
author | Jan Nieuwenhuizen <janneke@gnu.org> | 2006-02-01 19:26:02 +0000 |
---|---|---|
committer | Jan Nieuwenhuizen <janneke@gnu.org> | 2006-02-01 19:26:02 +0000 |
commit | 04b270fd7b1e63fb30c45f661a7492020526f0a9 (patch) | |
tree | ef406d61e8f6a9c8014fd785cdb6a3134e141d0f | |
parent | 3941d2a37ba8631459cdb9ec2c7f9993845d1300 (diff) |
* flower/test-std.cc: Add simple unit test for vector migration.
* stepmake/stepmake/test*: Unit test support.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | flower/GNUmakefile | 13 | ||||
-rw-r--r-- | flower/include/std-vector.hh | 15 | ||||
-rw-r--r-- | flower/test-std.cc | 45 | ||||
-rw-r--r-- | stepmake/stepmake/test-rules.make | 11 | ||||
-rw-r--r-- | stepmake/stepmake/test-targets.make | 6 | ||||
-rw-r--r-- | stepmake/stepmake/test-vars.make | 5 |
7 files changed, 82 insertions, 17 deletions
@@ -1,5 +1,9 @@ 2006-02-01 Jan Nieuwenhuizen <janneke@gnu.org> + * flower/test-std.cc: Add simple unit test for vector migration. + + * stepmake/stepmake/test*: Unit test support. + * flower/include/std-vector.hh (del): Remove. Use erase (), update callers. diff --git a/flower/GNUmakefile b/flower/GNUmakefile index 9a36eea33f..6c78043142 100644 --- a/flower/GNUmakefile +++ b/flower/GNUmakefile @@ -1,8 +1,3 @@ -# title top level makefile for FlowerLib -# file flower/Makefile - -# should reinstate versioning if shared libs are enabled. - depth = .. NAME = flower @@ -12,12 +7,6 @@ SUBDIRS = include SCRIPTS = README_FILES = NEWS-1.0 NEWS-1.1.46 README TODO EXTRA_DIST_FILES= VERSION $(README_FILES) $(SCRIPTS) -STEPMAKE_TEMPLATES=library c++ po - - +STEPMAKE_TEMPLATES=library c++ po test include $(depth)/make/stepmake.make - -foo: - echo $(DIST_FILES) $(O_FILES) $(OBJECT_FILES) - diff --git a/flower/include/std-vector.hh b/flower/include/std-vector.hh index ce88a5d628..db6cb9241e 100644 --- a/flower/include/std-vector.hh +++ b/flower/include/std-vector.hh @@ -260,6 +260,7 @@ namespace std { return VPOS; } #endif + } @@ -268,14 +269,18 @@ namespace std { namespace std { +#ifndef Array #define vector Array - using namespace std; +#endif - #ifndef VSIZE - #define VSIZE + using namespace std; + +#ifndef VSIZE +#define VSIZE typedef int vsize; - #define VPOS -1 - #endif +#define VPOS -1 +#endif + } diff --git a/flower/test-std.cc b/flower/test-std.cc new file mode 100644 index 0000000000..85e0a372fa --- /dev/null +++ b/flower/test-std.cc @@ -0,0 +1,45 @@ +#if !STD_VECTOR +#define Array flower_vector +#endif +#include "std-vector.hh" + +#include <iostream> + +#include <boost/test/auto_unit_test.hpp> +#include <boost/test/floating_point_comparison.hpp> + +using boost::unit_test::test_suite; + +template<typename T> +void +print (vector<T> v) +{ + for (vsize i = 0; i < v.size (); i++) + cout << "v[" << i << "] = " << v[i] << endl; +} + +BOOST_AUTO_UNIT_TEST (vector_erase) +{ + vector<int> v; + v.push_back (0); + v.push_back (1); + BOOST_CHECK_EQUAL (v.size (), 2u); + v.erase (v.begin () + 1); + BOOST_CHECK_EQUAL (v.size (), 1u); + BOOST_CHECK_EQUAL (v.back (), 0); + + v.push_back (1); + BOOST_CHECK_EQUAL (v.size (), 2u); + v.erase (v.begin () + 0); + BOOST_CHECK_EQUAL (v.size (), 1u); + BOOST_CHECK_EQUAL (v.back (), 1); +} + + +test_suite* +init_unit_test_suite (int, char**) +{ + test_suite *test = BOOST_TEST_SUITE("std::Flower"); + test->add (BOOST_TEST_CASE (vector_erase)); + return test; +} diff --git a/stepmake/stepmake/test-rules.make b/stepmake/stepmake/test-rules.make new file mode 100644 index 0000000000..d733dbbe69 --- /dev/null +++ b/stepmake/stepmake/test-rules.make @@ -0,0 +1,11 @@ + +define MODULE_LIB_template \ +$(1)/$(outdir)/library.a : \ + $(MAKE) -C $(1) +endef + +$(foreach a, $(MODULE_LIBS), $(eval $(call MODULE_LIB_template,$(a)))) + +$(TEST_EXECUTABLE): $(outdir)/config.hh $(TEST_O_FILES) $(TEST_MODULE_LIBS:%=%/$(outdir)/library.a) + $(foreach a, $(TEST_MODULE_LIBS), $(MAKE) -C $(a) && ) true + $(LD) -o $@ $(TEST_O_FILES) $(TEST_LOADLIBES) $(ALL_LDFLAGS) diff --git a/stepmake/stepmake/test-targets.make b/stepmake/stepmake/test-targets.make new file mode 100644 index 0000000000..fd74538aae --- /dev/null +++ b/stepmake/stepmake/test-targets.make @@ -0,0 +1,6 @@ +.PHONY: check test + +check: test + +test: $(TEST_EXECUTABLE) + $(TEST_EXECUTABLE) diff --git a/stepmake/stepmake/test-vars.make b/stepmake/stepmake/test-vars.make new file mode 100644 index 0000000000..ffabc1bd29 --- /dev/null +++ b/stepmake/stepmake/test-vars.make @@ -0,0 +1,5 @@ +TEST_O_FILES := $(filter $(outdir)/test%, $(O_FILES)) +O_FILES := $(filter-out $(outdir)/test%, $(O_FILES)) + +TEST_EXECUTABLE = $(outdir)/test-$(NAME) +TEST_LOADLIBES = $(LOADLIBES) -lboost_unit_test_framework |