diff options
Diffstat (limited to 'googletest/samples/sample3_unittest.cc')
-rw-r--r-- | googletest/samples/sample3_unittest.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/googletest/samples/sample3_unittest.cc b/googletest/samples/sample3_unittest.cc index bf3877d..97ce55d 100644 --- a/googletest/samples/sample3_unittest.cc +++ b/googletest/samples/sample3_unittest.cc @@ -28,9 +28,6 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // A sample program demonstrating using Google C++ testing framework. -// -// Author: wan@google.com (Zhanyong Wan) - // In this example, we use a more advanced feature of Google Test called // test fixture. @@ -65,14 +62,14 @@ #include "sample3-inl.h" #include "gtest/gtest.h" - +namespace { // To use a test fixture, derive a class from testing::Test. -class QueueTest : public testing::Test { +class QueueTestSmpl3 : public testing::Test { protected: // You should make the members protected s.t. they can be // accessed from sub-classes. // virtual void SetUp() will be called before each test is run. You - // should define it if you need to initialize the varaibles. + // should define it if you need to initialize the variables. // Otherwise, this can be skipped. virtual void SetUp() { q1_.Enqueue(1); @@ -102,8 +99,8 @@ class QueueTest : public testing::Test { ASSERT_EQ(q->Size(), new_q->Size()); // Verifies the relationship between the elements of the two queues. - for ( const QueueNode<int> * n1 = q->Head(), * n2 = new_q->Head(); - n1 != NULL; n1 = n1->next(), n2 = n2->next() ) { + for (const QueueNode<int>*n1 = q->Head(), *n2 = new_q->Head(); + n1 != nullptr; n1 = n1->next(), n2 = n2->next()) { EXPECT_EQ(2 * n1->element(), n2->element()); } @@ -120,32 +117,33 @@ class QueueTest : public testing::Test { // instead of TEST. // Tests the default c'tor. -TEST_F(QueueTest, DefaultConstructor) { +TEST_F(QueueTestSmpl3, DefaultConstructor) { // You can access data in the test fixture here. EXPECT_EQ(0u, q0_.Size()); } // Tests Dequeue(). -TEST_F(QueueTest, Dequeue) { +TEST_F(QueueTestSmpl3, Dequeue) { int * n = q0_.Dequeue(); - EXPECT_TRUE(n == NULL); + EXPECT_TRUE(n == nullptr); n = q1_.Dequeue(); - ASSERT_TRUE(n != NULL); + ASSERT_TRUE(n != nullptr); EXPECT_EQ(1, *n); EXPECT_EQ(0u, q1_.Size()); delete n; n = q2_.Dequeue(); - ASSERT_TRUE(n != NULL); + ASSERT_TRUE(n != nullptr); EXPECT_EQ(2, *n); EXPECT_EQ(1u, q2_.Size()); delete n; } // Tests the Queue::Map() function. -TEST_F(QueueTest, Map) { +TEST_F(QueueTestSmpl3, Map) { MapTester(&q0_); MapTester(&q1_); MapTester(&q2_); } +} // namespace |