[svn] commit: r105 - in /branches/jinmei-cppunittests/src/lib/dns: name_cxxtest.h name_gtest.cc name_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Oct 20 07:11:13 UTC 2009
Author: jinmei
Date: Tue Oct 20 07:11:13 2009
New Revision: 105
Log:
added some more exception tests, fail tests
Modified:
branches/jinmei-cppunittests/src/lib/dns/name_cxxtest.h
branches/jinmei-cppunittests/src/lib/dns/name_gtest.cc
branches/jinmei-cppunittests/src/lib/dns/name_unittest.cc
Modified: branches/jinmei-cppunittests/src/lib/dns/name_cxxtest.h
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name_cxxtest.h (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name_cxxtest.h Tue Oct 20 07:11:13 2009
@@ -22,9 +22,11 @@
#include <cxxtest/TestSuite.h>
using ISC::DNS::Name;
+using ISC::DNS::DNSLabelTooLong;
class NameTest : public CxxTest::TestSuite {
public:
+ NameTest() : example_name(NULL) {}
void setUp() { example_name = new Name("www.example.com"); }
void tearDown() { delete example_name; }
@@ -40,6 +42,16 @@
example_name->to_text(true));
TS_ASSERT_EQUALS(std::string("www.example.com."),
example_name->to_text(false));
+ // This one should fail:
+ TS_ASSERT_EQUALS(std::string("www.isc.org"),
+ example_name->to_text(true));
+ }
+
+ void test_invalid_label()
+ {
+ TS_ASSERT_THROWS(Name invalidlabel("012345678901234567890123456789"
+ "0123456789012345678901234567890123456789"),
+ DNSLabelTooLong);
}
Name* example_name;
Modified: branches/jinmei-cppunittests/src/lib/dns/name_gtest.cc
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name_gtest.cc (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name_gtest.cc Tue Oct 20 07:11:13 2009
@@ -54,11 +54,15 @@
{
EXPECT_EQ(std::string("www.example.com"), example_name->to_text(true));
EXPECT_EQ(std::string("www.example.com."), example_name->to_text(false));
+ // This one should fail:
+ EXPECT_EQ(std::string("www.isc.org"), example_name->to_text(true));
+}
+
+TEST_F(NameTest, invalid_label)
+{
EXPECT_THROW(Name invalidlabel("012345678901234567890123456789"
"0123456789012345678901234567890123456789"),
DNSLabelTooLong);
- // This one should fail:
- EXPECT_EQ(std::string("www.isc.org"), example_name->to_text(true));
}
}
Modified: branches/jinmei-cppunittests/src/lib/dns/name_unittest.cc
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name_unittest.cc (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name_unittest.cc Tue Oct 20 07:11:13 2009
@@ -21,14 +21,17 @@
#include <dns/name.h>
using ISC::DNS::Name;
+using ISC::DNS::DNSLabelTooLong;
class NameTest : public CppUnit::TestFixture {
void get_length();
void to_text();
+ void invalid_label();
CPPUNIT_TEST_SUITE(NameTest);
CPPUNIT_TEST(get_length);
CPPUNIT_TEST(to_text);
+ CPPUNIT_TEST_EXCEPTION(invalid_label, DNSLabelTooLong);
CPPUNIT_TEST_SUITE_END();
public:
NameTest() { example_name = NULL; }
@@ -66,4 +69,14 @@
example_name->to_text(true));
CPPUNIT_ASSERT_EQUAL(std::string("www.example.com."),
example_name->to_text(false));
+ // This one should fail:
+ CPPUNIT_ASSERT_EQUAL(std::string("www.isc.org"),
+ example_name->to_text(true));
}
+
+void
+NameTest::invalid_label()
+{
+ Name invalidlabel("012345678901234567890123456789"
+ "0123456789012345678901234567890123456789");
+}
More information about the bind10-changes
mailing list