BIND 10 trac510, updated. 4b57a79735953705a82d8595a8ac541f7deb7a74 [510] move initialization in every test case into fixture

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Dec 8 05:45:51 UTC 2011


The branch, trac510 has been updated
       via  4b57a79735953705a82d8595a8ac541f7deb7a74 (commit)
      from  60fd293717cc45323cfb10cf06d5bd264fa083cc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4b57a79735953705a82d8595a8ac541f7deb7a74
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Thu Dec 8 14:43:47 2011 +0900

    [510] move initialization in every test case into fixture

-----------------------------------------------------------------------

Summary of changes:
 src/lib/statistics/tests/counter_dict_unittest.cc |   60 +++++---------------
 src/lib/statistics/tests/counter_unittest.cc      |   12 ++--
 2 files changed, 21 insertions(+), 51 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/statistics/tests/counter_dict_unittest.cc b/src/lib/statistics/tests/counter_dict_unittest.cc
index 2e635be..d093e3d 100644
--- a/src/lib/statistics/tests/counter_dict_unittest.cc
+++ b/src/lib/statistics/tests/counter_dict_unittest.cc
@@ -30,18 +30,25 @@ enum CounterItems {
 
 using namespace isc::statistics;
 
+TEST(CounterDictionaryCreateTest, invalidCounterSize) {
+    // Creating counter with 0 elements will cause an isc::InvalidParameter
+    // exception
+    EXPECT_THROW(CounterDictionary counters(0), isc::InvalidParameter);
+}
+
 // This fixture is for testing CounterDictionary.
 class CounterDictionaryTest : public ::testing::Test {
 protected:
-    CounterDictionaryTest() {}
+    CounterDictionaryTest() : counters(NUMBER_OF_ITEMS) {
+        counters.addElement("test");
+        counters.addElement("sub.test");
+    }
     ~CounterDictionaryTest() {}
+
+    CounterDictionary counters;
 };
 
-TEST_F(CounterDictionaryTest, createCounterDictionary) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add an element for this test
-    counters.addElement("test");
+TEST_F(CounterDictionaryTest, initializeCheck) {
     // Check if the all counters are initialized with 0
     EXPECT_EQ(counters["test"].get(ITEM1), 0);
     EXPECT_EQ(counters["test"].get(ITEM2), 0);
@@ -49,10 +56,6 @@ TEST_F(CounterDictionaryTest, createCounterDictionary) {
 }
 
 TEST_F(CounterDictionaryTest, getElement) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add an element for this test
-    counters.addElement("test");
     // Another member function to get counters for the element
     EXPECT_EQ(counters.getElement("test").get(ITEM1), 0);
     EXPECT_EQ(counters.getElement("test").get(ITEM2), 0);
@@ -60,11 +63,6 @@ TEST_F(CounterDictionaryTest, getElement) {
 }
 
 TEST_F(CounterDictionaryTest, incrementCounterItem) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add elements for this test
-    counters.addElement("test");
-    counters.addElement("sub.test");
     // Increment counters
     counters["test"].inc(ITEM1);
     counters["test"].inc(ITEM2);
@@ -82,10 +80,6 @@ TEST_F(CounterDictionaryTest, incrementCounterItem) {
 }
 
 TEST_F(CounterDictionaryTest, deleteElement) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add an element for this test
-    counters.addElement("test");
     // Ensure the element is accessible
     EXPECT_EQ(counters["test"].get(ITEM1), 0);
     EXPECT_EQ(counters["test"].get(ITEM2), 0);
@@ -99,38 +93,19 @@ TEST_F(CounterDictionaryTest, deleteElement) {
     EXPECT_THROW(counters.deleteElement("test"), isc::OutOfRange);
 }
 
-TEST_F(CounterDictionaryTest, invalidCounterSize) {
-    // Creating counter with 0 elements will cause an isc::InvalidParameter
-    // exception
-    EXPECT_THROW(CounterDictionary counters(0), isc::InvalidParameter);
-}
-
 TEST_F(CounterDictionaryTest, invalidCounterItem) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add an element for this test
-    counters.addElement("test");
     // Incrementing out-of-bound counter will cause an isc::OutOfRange
     // exception
     EXPECT_THROW(counters["test"].inc(NUMBER_OF_ITEMS), isc::OutOfRange);
 }
 
-TEST_F(CounterDictionaryTest, uniqueCheck) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add an element for this test
-    counters.addElement("test");
+TEST_F(CounterDictionaryTest, uniquenessCheck) {
     // Adding an element which already exists will cause an isc::OutOfRange
     //  exception 
     EXPECT_THROW(counters.addElement("test"), isc::InvalidParameter);
 }
 
 TEST_F(CounterDictionaryTest, iteratorTest) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add elements for this test
-    counters.addElement("test");
-    counters.addElement("sub.test");
     // Increment counters
     counters["test"].inc(ITEM1);
     counters["sub.test"].inc(ITEM2);
@@ -163,17 +138,12 @@ TEST_F(CounterDictionaryTest, iteratorTest) {
             FAIL() << "Unexpected iterator value";
         }
     }
-    // Check if the "test" and "sub.test" could be accessed
+    // Check if the "test" and "sub.test" is accessible
     EXPECT_TRUE(element_test_visited);
     EXPECT_TRUE(element_sub_test_visited);
 }
 
 TEST_F(CounterDictionaryTest, iteratorCopyTest) {
-    // Create counters
-    CounterDictionary counters(NUMBER_OF_ITEMS);
-    // Add elements for this test
-    counters.addElement("test");
-    counters.addElement("sub.test");
     // Increment counters
     counters["test"].inc(ITEM1);
     counters["sub.test"].inc(ITEM2);
diff --git a/src/lib/statistics/tests/counter_unittest.cc b/src/lib/statistics/tests/counter_unittest.cc
index 57d830d..e0d29ac 100644
--- a/src/lib/statistics/tests/counter_unittest.cc
+++ b/src/lib/statistics/tests/counter_unittest.cc
@@ -28,6 +28,12 @@ enum CounterItems {
 
 using namespace isc::statistics;
 
+TEST(CounterCreateTest, invalidCounterSize) {
+    // Creating counter with 0 elements will cause an isc::InvalidParameter
+    // exception
+    EXPECT_THROW(Counter counter(0), isc::InvalidParameter);
+}
+
 // This fixture is for testing Counter.
 class CounterTest : public ::testing::Test {
 protected:
@@ -69,12 +75,6 @@ TEST_F(CounterTest, incrementCounterItem) {
     EXPECT_EQ(counter.get(ITEM3), 6);
 }
 
-TEST_F(CounterTest, invalidCounterSize) {
-    // Creating counter with 0 elements will cause an isc::InvalidParameter
-    // exception
-    EXPECT_THROW(Counter counter(0), isc::InvalidParameter);
-}
-
 TEST_F(CounterTest, invalidCounterItem) {
     // Incrementing out-of-bound counter will cause an isc::OutOfRange
     // exception




More information about the bind10-changes mailing list