* stepmake/stepmake/test*: Unit test support.
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.
-# title top level makefile for FlowerLib
-# file flower/Makefile
-
-# should reinstate versioning if shared libs are enabled.
-
depth = ..
NAME = flower
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)
-
return VPOS;
}
#endif
+
}
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
+
}
--- /dev/null
+#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;
+}
--- /dev/null
+
+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)
--- /dev/null
+.PHONY: check test
+
+check: test
+
+test: $(TEST_EXECUTABLE)
+ $(TEST_EXECUTABLE)
--- /dev/null
+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