Commit 60fd2937 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[510] move declaration into fixture

parent 2142e8e6
...@@ -31,13 +31,13 @@ using namespace isc::statistics; ...@@ -31,13 +31,13 @@ using namespace isc::statistics;
// This fixture is for testing Counter. // This fixture is for testing Counter.
class CounterTest : public ::testing::Test { class CounterTest : public ::testing::Test {
protected: protected:
CounterTest() {} CounterTest() : counter(NUMBER_OF_ITEMS) {}
~CounterTest() {} ~CounterTest() {}
Counter counter;
}; };
TEST_F(CounterTest, createCounter) { TEST_F(CounterTest, createCounter) {
// Create counter
Counter counter(NUMBER_OF_ITEMS);
// Check if the all counters are initialized with 0 // Check if the all counters are initialized with 0
EXPECT_EQ(counter.get(ITEM1), 0); EXPECT_EQ(counter.get(ITEM1), 0);
EXPECT_EQ(counter.get(ITEM2), 0); EXPECT_EQ(counter.get(ITEM2), 0);
...@@ -45,8 +45,6 @@ TEST_F(CounterTest, createCounter) { ...@@ -45,8 +45,6 @@ TEST_F(CounterTest, createCounter) {
} }
TEST_F(CounterTest, incrementCounterItem) { TEST_F(CounterTest, incrementCounterItem) {
// Create counter
Counter counter(NUMBER_OF_ITEMS);
// Increment counters // Increment counters
counter.inc(ITEM1); counter.inc(ITEM1);
counter.inc(ITEM2); counter.inc(ITEM2);
...@@ -78,8 +76,6 @@ TEST_F(CounterTest, invalidCounterSize) { ...@@ -78,8 +76,6 @@ TEST_F(CounterTest, invalidCounterSize) {
} }
TEST_F(CounterTest, invalidCounterItem) { TEST_F(CounterTest, invalidCounterItem) {
// Create counter
Counter counter(NUMBER_OF_ITEMS);
// Incrementing out-of-bound counter will cause an isc::OutOfRange // Incrementing out-of-bound counter will cause an isc::OutOfRange
// exception // exception
EXPECT_THROW(counter.inc(NUMBER_OF_ITEMS), isc::OutOfRange); EXPECT_THROW(counter.inc(NUMBER_OF_ITEMS), isc::OutOfRange);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment