From: Paul Selkirk Date: Tue, 7 May 2013 17:08:27 +0000 (-0400) Subject: [2522] more MINFO unit tests X-Git-Tag: bind10-1.2.0beta1-release~430^2~18^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1b78de66931aa416fda81f136b584f515561afd;p=thirdparty%2Fkea.git [2522] more MINFO unit tests --- diff --git a/src/lib/dns/tests/rdata_minfo_unittest.cc b/src/lib/dns/tests/rdata_minfo_unittest.cc index 4ef86b539a..7671565ffb 100644 --- a/src/lib/dns/tests/rdata_minfo_unittest.cc +++ b/src/lib/dns/tests/rdata_minfo_unittest.cc @@ -39,10 +39,26 @@ const char* const too_long_label = "01234567890123456789012345678901234567" namespace { class Rdata_MINFO_Test : public RdataTest { -public: +protected: Rdata_MINFO_Test(): rdata_minfo(string(minfo_txt)), rdata_minfo2(string(minfo_txt2)) {} + void checkFromText_None(const string& rdata_str) { + checkFromText( + rdata_str, rdata_minfo, false, false); + } + + void checkFromText_LexerError(const string& rdata_str) { + checkFromText + ( + rdata_str, rdata_minfo, true, true); + } + + void checkFromText_TooLongLabel(const string& rdata_str) { + checkFromText( + rdata_str, rdata_minfo, true, true); + } + const generic::MINFO rdata_minfo; const generic::MINFO rdata_minfo2; }; @@ -54,24 +70,23 @@ TEST_F(Rdata_MINFO_Test, createFromText) { EXPECT_EQ(Name("root.example.com."), rdata_minfo2.getRmailbox()); EXPECT_EQ(Name("emailbox.example.com."), rdata_minfo2.getEmailbox()); + + checkFromText_None(minfo_txt); } TEST_F(Rdata_MINFO_Test, badText) { // incomplete text - EXPECT_THROW(generic::MINFO("root.example.com."), - InvalidRdataText); + checkFromText_LexerError("root.example.com."); // number of fields (must be 2) is incorrect EXPECT_THROW(generic::MINFO("root.example.com. emailbox.example.com. " "example.com."), InvalidRdataText); // bad rmailbox name - EXPECT_THROW(generic::MINFO("root.example.com. emailbox.example.com." + - string(too_long_label)), - TooLongLabel); + checkFromText_TooLongLabel("root.example.com. emailbox.example.com." + + string(too_long_label)); // bad emailbox name - EXPECT_THROW(generic::MINFO("root.example.com." + - string(too_long_label) + " emailbox.example.com."), - TooLongLabel); + checkFromText_TooLongLabel("root.example.com." + string(too_long_label) + + " emailbox.example.com."); } TEST_F(Rdata_MINFO_Test, createFromWire) { @@ -107,6 +122,15 @@ TEST_F(Rdata_MINFO_Test, createFromLexer) { EXPECT_EQ(0, rdata_minfo.compare( *test::createRdataUsingLexer(RRType::MINFO(), RRClass::IN(), minfo_txt))); + + // test::createRdataUsingLexer() constructs relative to + // "example.org." origin. + EXPECT_EQ(0, generic::MINFO("r.example.org. e.example.org.").compare( + *test::createRdataUsingLexer(RRType::MINFO(), RRClass::IN(), "r e"))); + + // Extra text at end of line + EXPECT_FALSE(test::createRdataUsingLexer(RRType::MINFO(), RRClass::IN(), + "rmailbox.example.com. emailbox.example.com. extra.example.com.")); } TEST_F(Rdata_MINFO_Test, assignment) {