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) {
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
const RRsetCollection& ccln = collection;
ConstRRsetPtr rrset = ccln.find(Name("www.example.org"), rrclass,
RRType::A());
TP rrset = collection.find(Name("www.example.org"), rrclass, RRType::A());
EXPECT_TRUE(rrset);
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRTTL(3600), rrset->getTTL());
......@@ -72,39 +71,27 @@ TEST_F(RRsetCollectionTest, findConst) {
EXPECT_EQ(Name("www.example.org"), rrset->getName());
// 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);
// 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);
// 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);
}
TEST_F(RRsetCollectionTest, find) {
TEST_F(RRsetCollectionTest, findConst) {
// Test the find() that returns ConstRRsetPtr
RRsetPtr rrset = collection.find(Name("www.example.org"), rrclass,
RRType::A());
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);
const RRsetCollection& ccln = collection;
doFind<const RRsetCollection, ConstRRsetPtr>(ccln, rrclass);
}
// www.example.org exists, with AAAA
rrset = collection.find(Name("www.example.org"), rrclass, RRType::AAAA());
EXPECT_TRUE(rrset);
TEST_F(RRsetCollectionTest, find) {
// Test the find() that returns RRsetPtr
doFind<RRsetCollection, RRsetPtr>(collection, rrclass);
}
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