From: Mukund Sivaraman Date: Mon, 24 Sep 2012 22:38:49 +0000 (+0530) Subject: [2218] Remove duplicate code from old memory datasrc test X-Git-Tag: trac2351_base~37^2~1^2~3^2~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6f8e26e272ee0d94c36bf2be23e005bd74c55ea;p=thirdparty%2Fkea.git [2218] Remove duplicate code from old memory datasrc test Though it strictly has nothing to do with this branch, this was the reason there was code duplication in #2109 to begin with. --- diff --git a/src/lib/datasrc/tests/memory_datasrc_unittest.cc b/src/lib/datasrc/tests/memory_datasrc_unittest.cc index f0a0c787e3..958c9e12c1 100644 --- a/src/lib/datasrc/tests/memory_datasrc_unittest.cc +++ b/src/lib/datasrc/tests/memory_datasrc_unittest.cc @@ -293,77 +293,6 @@ setRRset(RRsetPtr rrset, vector::iterator& it) { ++it; } -// Some faked NSEC3 hash values commonly used in tests and the faked NSEC3Hash -// object. -// -// For apex (example.org) -const char* const apex_hash = "0P9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM"; -const char* const apex_hash_lower = "0p9mhaveqvm6t7vbl5lop2u3t2rp3tom"; -// For ns1.example.org -const char* const ns1_hash = "2T7B4G4VSA5SMI47K61MV5BV1A22BOJR"; -// For w.example.org -const char* const w_hash = "01UDEMVP1J2F7EG6JEBPS17VP3N8I58H"; -// For x.y.w.example.org (lower-cased) -const char* const xyw_hash = "2vptu5timamqttgl4luu9kg21e0aor3s"; -// For zzz.example.org. -const char* const zzz_hash = "R53BQ7CC2UVMUBFU5OCMM6PERS9TK9EN"; - -// A simple faked NSEC3 hash calculator with a dedicated creator for it. -// -// This is used in some NSEC3-related tests below. -class TestNSEC3HashCreator : public NSEC3HashCreator { - class TestNSEC3Hash : public NSEC3Hash { - private: - typedef map NSEC3HashMap; - typedef NSEC3HashMap::value_type NSEC3HashPair; - NSEC3HashMap map_; - public: - TestNSEC3Hash() { - // Build pre-defined hash - map_[Name("example.org")] = apex_hash; - map_[Name("www.example.org")] = "2S9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM"; - map_[Name("xxx.example.org")] = "Q09MHAVEQVM6T7VBL5LOP2U3T2RP3TOM"; - map_[Name("yyy.example.org")] = "0A9MHAVEQVM6T7VBL5LOP2U3T2RP3TOM"; - map_[Name("x.y.w.example.org")] = - "2VPTU5TIMAMQTTGL4LUU9KG21E0AOR3S"; - map_[Name("y.w.example.org")] = "K8UDEMVP1J2F7EG6JEBPS17VP3N8I58H"; - map_[Name("w.example.org")] = w_hash; - map_[Name("zzz.example.org")] = zzz_hash; - map_[Name("smallest.example.org")] = - "00000000000000000000000000000000"; - map_[Name("largest.example.org")] = - "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"; - } - virtual string calculate(const Name& name) const { - const NSEC3HashMap::const_iterator found = map_.find(name); - if (found != map_.end()) { - return (found->second); - } - isc_throw(isc::Unexpected, "unexpected name for NSEC3 test: " - << name); - } - virtual bool match(const generic::NSEC3PARAM&) const { - return (true); - } - virtual bool match(const generic::NSEC3&) const { - return (true); - } - }; - -public: - virtual NSEC3Hash* create(const generic::NSEC3PARAM&) const { - return (new TestNSEC3Hash); - } - virtual NSEC3Hash* create(const generic::NSEC3&) const { - return (new TestNSEC3Hash); - } - virtual NSEC3Hash* create(uint8_t, uint16_t, - const vector&) const { - return (new TestNSEC3Hash); -} - -}; - /// \brief Test fixture for the InMemoryZoneFinder class class InMemoryZoneFinderTest : public ::testing::Test { // A straightforward pair of textual RR(set) and a RRsetPtr variable