Commit b5aa1d1b authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2432] Unify common test code

parent 2fc0ce20
...@@ -60,11 +60,10 @@ TEST_F(RRsetCollectionTest, findBase) { ...@@ -60,11 +60,10 @@ TEST_F(RRsetCollectionTest, findBase) {
EXPECT_NE(static_cast<AbstractRRset*>(NULL), rrset); EXPECT_NE(static_cast<AbstractRRset*>(NULL), rrset);
} }
TEST_F(RRsetCollectionTest, findConst) { template <typename T, typename TP>
void doFind(T& collection, const RRClass& rrclass) {
// Test the find() that returns ConstRRsetPtr // Test the find() that returns ConstRRsetPtr
const RRsetCollection& ccln = collection; TP rrset = collection.find(Name("www.example.org"), rrclass, RRType::A());
ConstRRsetPtr rrset = ccln.find(Name("www.example.org"), rrclass,
RRType::A());
EXPECT_TRUE(rrset); EXPECT_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());
...@@ -72,39 +71,27 @@ TEST_F(RRsetCollectionTest, findConst) { ...@@ -72,39 +71,27 @@ TEST_F(RRsetCollectionTest, findConst) {
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 = ccln.find(Name("foo.example.org"), rrclass, RRType::A()); rrset = collection.find(Name("foo.example.org"), rrclass, 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 = ccln.find(Name("www.example.org"), rrclass, RRType::MX()); rrset = collection.find(Name("www.example.org"), rrclass, RRType::MX());
EXPECT_FALSE(rrset); EXPECT_FALSE(rrset);
// www.example.org exists, with AAAA // www.example.org exists, with AAAA
rrset = ccln.find(Name("www.example.org"), rrclass, RRType::AAAA()); rrset = collection.find(Name("www.example.org"), rrclass, RRType::AAAA());
EXPECT_TRUE(rrset); EXPECT_TRUE(rrset);
} }
TEST_F(RRsetCollectionTest, find) { TEST_F(RRsetCollectionTest, findConst) {
// Test the find() that returns ConstRRsetPtr // Test the find() that returns ConstRRsetPtr
RRsetPtr rrset = collection.find(Name("www.example.org"), rrclass, const RRsetCollection& ccln = collection;
RRType::A()); doFind<const RRsetCollection, ConstRRsetPtr>(ccln, rrclass);
EXPECT_TRUE(rrset); }
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRTTL(3600), rrset->getTTL());
EXPECT_EQ(RRClass("IN"), rrset->getClass());
EXPECT_EQ(Name("www.example.org"), rrset->getName());
// foo.example.org doesn't exist
rrset = collection.find(Name("foo.example.org"), rrclass, RRType::A());
EXPECT_FALSE(rrset);
// www.example.org exists, but not with MX
rrset = collection.find(Name("www.example.org"), rrclass, RRType::MX());
EXPECT_FALSE(rrset);
// www.example.org exists, with AAAA TEST_F(RRsetCollectionTest, find) {
rrset = collection.find(Name("www.example.org"), rrclass, RRType::AAAA()); // Test the find() that returns RRsetPtr
EXPECT_TRUE(rrset); doFind<RRsetCollection, RRsetPtr>(collection, rrclass);
} }
TEST_F(RRsetCollectionTest, addAndRemove) { TEST_F(RRsetCollectionTest, addAndRemove) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment