]> git.donarmstrong.com Git - lilypond.git/commitdiff
* flower/test-std.cc: Add simple unit test for vector migration.
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 1 Feb 2006 19:26:02 +0000 (19:26 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 1 Feb 2006 19:26:02 +0000 (19:26 +0000)
* stepmake/stepmake/test*: Unit test support.

ChangeLog
flower/GNUmakefile
flower/include/std-vector.hh
flower/test-std.cc [new file with mode: 0644]
stepmake/stepmake/test-rules.make [new file with mode: 0644]
stepmake/stepmake/test-targets.make [new file with mode: 0644]
stepmake/stepmake/test-vars.make [new file with mode: 0644]

index fa887d06d70f607bd3c2888898fe5144bb277a16..df45f6d6c37ee6b93a09eacd5a361d923c7239df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
 
index 9a36eea33f3e332496339010f37057f5889ebd70..6c7804314247928f6de5021d4048ee8001c27f26 100644 (file)
@@ -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)
-
index ce88a5d6285055872c449eb0b4773be13ff09d38..db6cb9241e486d287eecf32786353a62fa5b8e52 100644 (file)
@@ -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 (file)
index 0000000..85e0a37
--- /dev/null
@@ -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 (file)
index 0000000..d733dbb
--- /dev/null
@@ -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 (file)
index 0000000..fd74538
--- /dev/null
@@ -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 (file)
index 0000000..ffabc1b
--- /dev/null
@@ -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