[Debtags-commits] [svn] r1559 - in tagcoll/trunk: . tagcoll tests

Enrico Zini enrico at costa.debian.org
Sat Feb 11 12:24:47 UTC 2006


Author: enrico
Date: Sat Feb 11 12:24:46 2006
New Revision: 1559

Modified:
   tagcoll/trunk/   (props changed)
   tagcoll/trunk/tagcoll/CardinalityStore.cc
   tagcoll/trunk/tagcoll/InputMerger.cc
   tagcoll/trunk/tagcoll/IntDiskIndex.cc
   tagcoll/trunk/tagcoll/IntIndex.cc
   tagcoll/trunk/tagcoll/ItemGrouper.cc
   tagcoll/trunk/tagcoll/PatchCollection.cc
   tagcoll/trunk/tagcoll/TDBDiskIndex.cc
   tagcoll/trunk/tagcoll/TDBIndexer.cc
   tagcoll/trunk/tagcoll/TDBReadonlyDiskIndex.cc
   tagcoll/trunk/tagcoll/test-utils.cc
   tagcoll/trunk/tests/test-utils.h
Log:
 r7213 at viaza:  enrico | 2006-02-10 12:03:22 +0100
 Used the readonly collection tests for all collections


Modified: tagcoll/trunk/tagcoll/CardinalityStore.cc
==============================================================================
--- tagcoll/trunk/tagcoll/CardinalityStore.cc	(original)
+++ tagcoll/trunk/tagcoll/CardinalityStore.cc	Sat Feb 11 12:24:46 2006
@@ -692,7 +692,16 @@
 {
 	CardinalityStore<string, string> coll;
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+}
+
+template<> template<>
+void to::test<2>()
+{
+	CardinalityStore<string, string> coll;
+
+	test_collection(coll);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/InputMerger.cc
==============================================================================
--- tagcoll/trunk/tagcoll/InputMerger.cc	(original)
+++ tagcoll/trunk/tagcoll/InputMerger.cc	Sat Feb 11 12:24:46 2006
@@ -198,7 +198,16 @@
 {
 	InputMerger<string, string> coll;
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+}
+
+template<> template<>
+void to::test<2>()
+{
+	InputMerger<string, string> coll;
+
+	test_collection(coll);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/IntDiskIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/IntDiskIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/IntDiskIndex.cc	Sat Feb 11 12:24:46 2006
@@ -312,7 +312,7 @@
 	}
 #endif
 	
-	test_tagged_collection_ro(idx);
+	test_readonly_collection(idx);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/IntIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/IntIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/IntIndex.cc	Sat Feb 11 12:24:46 2006
@@ -202,14 +202,14 @@
 	IntIndex index(fname);
 
 	// Check the number of mapped items
-	ensure_equals(index.size(), 5);
+	ensure_equals(index.size(), 5u);
 
 	// Check that the arrays have the right size
-	ensure_equals(index.size(0), 4);
-	ensure_equals(index.size(1), 0);
-	ensure_equals(index.size(2), 1);
-	ensure_equals(index.size(3), 0);
-	ensure_equals(index.size(4), 2);
+	ensure_equals(index.size(0), 4u);
+	ensure_equals(index.size(1), 0u);
+	ensure_equals(index.size(2), 1u);
+	ensure_equals(index.size(3), 0u);
+	ensure_equals(index.size(4), 2u);
 
 	// Check that the arrays are sorted and contain the right data
 	ensure_equals(index.data(0)[0], 1);

Modified: tagcoll/trunk/tagcoll/ItemGrouper.cc
==============================================================================
--- tagcoll/trunk/tagcoll/ItemGrouper.cc	(original)
+++ tagcoll/trunk/tagcoll/ItemGrouper.cc	Sat Feb 11 12:24:46 2006
@@ -44,7 +44,16 @@
 {
 	ItemGrouper<string, string> coll;
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+}
+
+template<> template<>
+void to::test<2>()
+{
+	ItemGrouper<string, string> coll;
+
+	test_collection(coll);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/PatchCollection.cc
==============================================================================
--- tagcoll/trunk/tagcoll/PatchCollection.cc	(original)
+++ tagcoll/trunk/tagcoll/PatchCollection.cc	Sat Feb 11 12:24:46 2006
@@ -234,7 +234,19 @@
 
 	PatchCollection<string, string> coll(startcoll);
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+}
+
+template<> template<>
+void to::test<2>()
+{
+	// Use an InputMerger as the embedded collection
+	InputMerger<string, string> startcoll;
+
+	PatchCollection<string, string> coll(startcoll);
+
+	test_collection(coll);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/TDBDiskIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/TDBDiskIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/TDBDiskIndex.cc	Sat Feb 11 12:24:46 2006
@@ -264,7 +264,20 @@
 	Converter<string, string> a;
 	TDBDiskIndex<string, string> coll("pkgidx.test", "tagidx.test", a, a, a, a);
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+
+	unlink("pkgidx.test");
+	unlink("tagidx.test");
+}
+
+template<> template<>
+void to::test<2>()
+{
+	Converter<string, string> a;
+	TDBDiskIndex<string, string> coll("pkgidx.test", "tagidx.test", a, a, a, a);
+
+	test_collection(coll);
 
 	unlink("pkgidx.test");
 	unlink("tagidx.test");

Modified: tagcoll/trunk/tagcoll/TDBIndexer.cc
==============================================================================
--- tagcoll/trunk/tagcoll/TDBIndexer.cc	(original)
+++ tagcoll/trunk/tagcoll/TDBIndexer.cc	Sat Feb 11 12:24:46 2006
@@ -204,7 +204,16 @@
 {
 	TDBIndexer<string, string> coll;
 
-	test_tagged_collection(coll);
+	output_test_collection(coll);
+	test_readonly_collection(coll);
+}
+
+template<> template<>
+void to::test<2>()
+{
+	TDBIndexer<string, string> coll;
+
+	test_collection(coll);
 }
 
 }

Modified: tagcoll/trunk/tagcoll/TDBReadonlyDiskIndex.cc
==============================================================================
--- tagcoll/trunk/tagcoll/TDBReadonlyDiskIndex.cc	(original)
+++ tagcoll/trunk/tagcoll/TDBReadonlyDiskIndex.cc	Sat Feb 11 12:24:46 2006
@@ -33,6 +33,7 @@
 #ifdef COMPILE_TESTSUITE
 
 #include <tests/test-utils.h>
+#include <tagcoll/TDBIndexer.h>
 
 namespace tut {
 using namespace tut_tagcoll;
@@ -45,9 +46,28 @@
 void to::test<1>()
 {
 	Converter<string, string> a;
+
+	// Create the collection on disk
+	{
+		TDBIndexer<string, string> rwcoll;
+		output_test_collection(rwcoll);
+		rwcoll.writeIndex(a, a, "pkgidx.test", "tagidx.test");
+	}
+
+	TDBReadonlyDiskIndex<string, string> coll("pkgidx.test", "tagidx.test", a, a, a, a);
+	test_readonly_collection(coll);
+
+	unlink("pkgidx.test");
+	unlink("tagidx.test");
+}
+
+template<> template<>
+void to::test<2>()
+{
+	Converter<string, string> a;
 	TDBReadonlyDiskIndex<string, string> coll("pkgidx.test", "tagidx.test", a, a, a, a);
 
-	test_tagged_collection(coll);
+	test_collection(coll);
 
 	unlink("pkgidx.test");
 	unlink("tagidx.test");

Modified: tagcoll/trunk/tagcoll/test-utils.cc
==============================================================================
--- tagcoll/trunk/tagcoll/test-utils.cc	(original)
+++ tagcoll/trunk/tagcoll/test-utils.cc	Sat Feb 11 12:24:46 2006
@@ -118,7 +118,7 @@
 	tc.consume("rosmarino", tagset);
 }
 
-void __test_tagged_collection_ro(const Location& loc, ReadonlyCollection<string, string>& tc)
+void __test_readonly_collection(const Location& loc, ReadonlyCollection<string, string>& tc)
 {
 	OpSet<string> s, s1;
 
@@ -175,7 +175,7 @@
 	inner_ensure(s.contains("rosemerry"));
 }
 
-void __test_tagged_collection(const Location& loc, Collection<string, string>& tc)
+void __test_collection(const Location& loc, Collection<string, string>& tc)
 {
 	// Test handling of untagged items (they are not stored)
 	tc.consume("untagged");

Modified: tagcoll/trunk/tests/test-utils.h
==============================================================================
--- tagcoll/trunk/tests/test-utils.h	(original)
+++ tagcoll/trunk/tests/test-utils.h	Sat Feb 11 12:24:46 2006
@@ -150,13 +150,13 @@
 #define inner_output_test_collection(x) (__output_test_collection(Location(loc, __FILE__, __LINE__, $x), (x)))
 void __output_test_collection(const Location& loc, Consumer<string, string>& tc);
 
-#define test_tagged_collection_ro(x) (__test_tagged_collection_ro(Location(__FILE__, __LINE__, #x), (x)))
-#define inner_test_tagged_collection_ro(x) (__test_tagged_collection_ro(Location(loc, __FILE__, __LINE__, #x), (x)))
-void __test_tagged_collection_ro(const Location& loc, ReadonlyCollection<string, string>& tc);
+#define test_readonly_collection(x) (__test_readonly_collection(Location(__FILE__, __LINE__, #x), (x)))
+#define inner_test_readonly_collection(x) (__test_readonly_collection(Location(loc, __FILE__, __LINE__, #x), (x)))
+void __test_readonly_collection(const Location& loc, ReadonlyCollection<string, string>& tc);
 
 
-#define test_tagged_collection(x) (__test_tagged_collection(Location(__FILE__, __LINE__, #x), (x)))
-void __test_tagged_collection(const Location& loc, Collection<string, string>& tc);
+#define test_collection(x) (__test_collection(Location(__FILE__, __LINE__, #x), (x)))
+void __test_collection(const Location& loc, Collection<string, string>& tc);
 
 #endif
 }



More information about the Debtags-commits mailing list