Browse Source

[2435] Test RRsetCollection against both MockAccessor and TestSQLite3Accessor

Mukund Sivaraman 12 years ago
parent
commit
6c0febf6e8
1 changed files with 20 additions and 11 deletions
  1. 20 11
      src/lib/datasrc/tests/database_unittest.cc

+ 20 - 11
src/lib/datasrc/tests/database_unittest.cc

@@ -4152,20 +4152,26 @@ TYPED_TEST(DatabaseClientTest, createZoneRollbackOnExists) {
     ASSERT_TRUE(this->client_->createZone(new_name));
     ASSERT_TRUE(this->client_->createZone(new_name));
 }
 }
 
 
-class RRsetCollectionTest : public DatabaseClientTest<TestSQLite3Accessor> {
+TYPED_TEST_CASE(RRsetCollectionTest, TestAccessorTypes);
+
+// This test fixture is templated so that we can share (most of) the test
+// cases with different types of data sources.  Note that in test cases
+// we need to use 'this' to refer to member variables of the test class.
+template <typename ACCESSOR_TYPE>
+class RRsetCollectionTest : public DatabaseClientTest<ACCESSOR_TYPE> {
 public:
 public:
     RRsetCollectionTest() :
     RRsetCollectionTest() :
-        DatabaseClientTest<TestSQLite3Accessor>(),
+        DatabaseClientTest<ACCESSOR_TYPE>(),
         collection(this->client_->getUpdater(this->zname_, false))
         collection(this->client_->getUpdater(this->zname_, false))
     {}
     {}
 
 
     RRsetCollection collection;
     RRsetCollection collection;
 };
 };
 
 
-TEST_F(RRsetCollectionTest, find) {
+TYPED_TEST(RRsetCollectionTest, find) {
     // Test the find() that returns ConstRRsetPtr
     // Test the find() that returns ConstRRsetPtr
-    ConstRRsetPtr rrset = collection.find(Name("www.example.org."),
-                                          RRClass::IN(), RRType::A());
+    ConstRRsetPtr rrset = this->collection.find(Name("www.example.org."),
+                                                RRClass::IN(), RRType::A());
     ASSERT_TRUE(rrset);
     ASSERT_TRUE(rrset);
     EXPECT_EQ(RRType::A(), rrset->getType());
     EXPECT_EQ(RRType::A(), rrset->getType());
     EXPECT_EQ(RRTTL(3600), rrset->getTTL());
     EXPECT_EQ(RRTTL(3600), rrset->getTTL());
@@ -4173,22 +4179,25 @@ TEST_F(RRsetCollectionTest, find) {
     EXPECT_EQ(Name("www.example.org"), rrset->getName());
     EXPECT_EQ(Name("www.example.org"), rrset->getName());
 
 
     // foo.example.org doesn't exist
     // foo.example.org doesn't exist
-    rrset = collection.find(Name("foo.example.org"), qclass_, RRType::A());
+    rrset = this->collection.find(Name("foo.example.org"), this->qclass_,
+                                  RRType::A());
     EXPECT_FALSE(rrset);
     EXPECT_FALSE(rrset);
 
 
     // www.example.org exists, but not with MX
     // www.example.org exists, but not with MX
-    rrset = collection.find(Name("www.example.org"), qclass_, RRType::MX());
+    rrset = this->collection.find(Name("www.example.org"), this->qclass_,
+                                  RRType::MX());
     EXPECT_FALSE(rrset);
     EXPECT_FALSE(rrset);
 
 
     // www.example.org exists, with AAAA
     // www.example.org exists, with AAAA
-    rrset = collection.find(Name("www.example.org"), qclass_, RRType::AAAA());
+    rrset = this->collection.find(Name("www.example.org"), this->qclass_,
+                                  RRType::AAAA());
     EXPECT_TRUE(rrset);
     EXPECT_TRUE(rrset);
 }
 }
 
 
-TEST_F(RRsetCollectionTest, iteratorTest) {
+TYPED_TEST(RRsetCollectionTest, iteratorTest) {
     // Iterators are currently not implemented.
     // Iterators are currently not implemented.
-    EXPECT_THROW(collection.begin(), isc::NotImplemented);
-    EXPECT_THROW(collection.end(), isc::NotImplemented);
+    EXPECT_THROW(this->collection.begin(), isc::NotImplemented);
+    EXPECT_THROW(this->collection.end(), isc::NotImplemented);
 }
 }
 
 
 }
 }