[svn] commit: r101 - in /branches/jinmei-cppunittests/src/lib/dns: name.cc name.h name_gtest.cc name_unittest.cc name_unittest.h run_unittests.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Oct 20 05:53:40 UTC 2009


Author: jinmei
Date: Tue Oct 20 05:53:40 2009
New Revision: 101

Log:
use test suite registry in cppunit

Modified:
    branches/jinmei-cppunittests/src/lib/dns/name.cc
    branches/jinmei-cppunittests/src/lib/dns/name.h
    branches/jinmei-cppunittests/src/lib/dns/name_gtest.cc
    branches/jinmei-cppunittests/src/lib/dns/name_unittest.cc
    branches/jinmei-cppunittests/src/lib/dns/name_unittest.h
    branches/jinmei-cppunittests/src/lib/dns/run_unittests.cc

Modified: branches/jinmei-cppunittests/src/lib/dns/name.cc
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name.cc (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name.cc Tue Oct 20 05:53:40 2009
@@ -20,18 +20,6 @@
 
 using namespace std;
 using namespace ISC::DNS;
-
-// quick hack exception classes: should be moved to an appropriate place soon.
-class ISCException {};
-class ISCUnexpected : public ISCException {};
-class ISCNoSpace : public ISCException {};
-
-class DNSException {};
-class DNSEmptyLabel : public DNSException {};
-class DNSLabelTooLong : public DNSException {};
-class DNSBadEscape : public DNSException {};
-class DNSBadLabelType : public DNSException {};
-
 
 typedef enum {
     ft_init = 0,

Modified: branches/jinmei-cppunittests/src/lib/dns/name.h
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name.h (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name.h Tue Oct 20 05:53:40 2009
@@ -25,6 +25,17 @@
 class Buffer;
 class NameCompressor;
 class NameDecompressor;
+
+// quick hack exception classes: should be moved to an appropriate place soon.
+class ISCException {};
+class ISCUnexpected : public ISCException {};
+class ISCNoSpace : public ISCException {};
+
+class DNSException {};
+class DNSEmptyLabel : public DNSException {};
+class DNSLabelTooLong : public DNSException {};
+class DNSBadEscape : public DNSException {};
+class DNSBadLabelType : public DNSException {};
 
 class NameComparisonResult {
 public:

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 05:53:40 2009
@@ -19,6 +19,9 @@
 #include <gtest/gtest.h>
 
 namespace {
+
+using ISC::DNS::Name;
+using ISC::DNS::DNSLabelTooLong;
 
 // The fixture for testing class Name.
 class NameTest : public ::testing::Test {
@@ -51,6 +54,9 @@
 {
     EXPECT_EQ(std::string("www.example.com"), example_name->to_text(true));
     EXPECT_EQ(std::string("www.example.com."), example_name->to_text(false));
+    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 05:53:40 2009
@@ -16,12 +16,24 @@
 
 #include <string>
 
-#include <cppunit/TestAssert.h>
+#include <cppunit/extensions/HelperMacros.h>
 
 #include <dns/name.h>
-#include <dns/name_unittest.h>
 
 using ISC::DNS::Name;
+
+class NameTest : public CppUnit::TestFixture {
+public:
+    void get_length();
+    void to_text();
+
+    CPPUNIT_TEST_SUITE(NameTest);
+    CPPUNIT_TEST(get_length);
+    CPPUNIT_TEST(to_text);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(NameTest);
 
 void
 NameTest::get_length()

Modified: branches/jinmei-cppunittests/src/lib/dns/name_unittest.h
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/name_unittest.h (original)
+++ branches/jinmei-cppunittests/src/lib/dns/name_unittest.h Tue Oct 20 05:53:40 2009
@@ -1,37 +1,21 @@
-/*
- * Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
+// Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
 
-/* $Id$ */
+// $Id$
 
 #ifndef __NAME_UNITTEST_H
 #define __NAME_UNITTEST_H 1
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestFixture.h>
-
-class NameTest : public CppUnit::TestFixture {
-public:
-    void get_length();
-    void to_text();
-
-    CPPUNIT_TEST_SUITE(NameTest);
-    CPPUNIT_TEST(get_length);
-    CPPUNIT_TEST(to_text);
-    CPPUNIT_TEST_SUITE_END();
-};
 
 #endif // __NAME_UNITTEST_H
 

Modified: branches/jinmei-cppunittests/src/lib/dns/run_unittests.cc
==============================================================================
--- branches/jinmei-cppunittests/src/lib/dns/run_unittests.cc (original)
+++ branches/jinmei-cppunittests/src/lib/dns/run_unittests.cc Tue Oct 20 05:53:40 2009
@@ -23,8 +23,7 @@
 #include <cppunit/TestResultCollector.h>
 #include <cppunit/TestRunner.h>
 #include <cppunit/TextTestProgressListener.h>
-
-#include <dns/name_unittest.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
 
 int
 main(int argc, char* argv[])
@@ -40,7 +39,7 @@
     CppUnit::TextTestProgressListener progress;
     controller.addListener(&progress);
 
-    runner.addTest(NameTest::suite());
+    runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
 
     try {
         std::cout << "Running ";
@@ -51,7 +50,7 @@
         // Print test in a compiler compatible format.
         CppUnit::CompilerOutputter outputter(&result, std::cerr);
         outputter.write();                      
-    } catch (std::invalid_argument& e) {  // Test path not resolved
+    } catch (std::invalid_argument& e) {
         std::cerr  <<  std::endl  
                    <<  "ERROR: "  <<  e.what()
                    << std::endl;




More information about the bind10-changes mailing list