"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googletest/samples/sample5_unittest.cc" between
googletest-release-1.11.0.tar.gz and googletest-release-1.12.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

sample5_unittest.cc  (googletest-release-1.11.0):sample5_unittest.cc  (googletest-release-1.12.0)
skipping to change at line 47 skipping to change at line 47
// Sometimes, more than one test cases may want to use the same or // Sometimes, more than one test cases may want to use the same or
// slightly different test fixtures. For example, you may want to // slightly different test fixtures. For example, you may want to
// make sure that all tests for a GUI library don't leak important // make sure that all tests for a GUI library don't leak important
// system resources like fonts and brushes. In Google Test, you do // system resources like fonts and brushes. In Google Test, you do
// this by putting the shared logic in a super (as in "super class") // this by putting the shared logic in a super (as in "super class")
// test fixture, and then have each test case use a fixture derived // test fixture, and then have each test case use a fixture derived
// from this super fixture. // from this super fixture.
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
#include "gtest/gtest.h"
#include "sample1.h" #include "sample1.h"
#include "sample3-inl.h" #include "sample3-inl.h"
#include "gtest/gtest.h"
namespace { namespace {
// In this sample, we want to ensure that every test finishes within // In this sample, we want to ensure that every test finishes within
// ~5 seconds. If a test takes longer to run, we consider it a // ~5 seconds. If a test takes longer to run, we consider it a
// failure. // failure.
// //
// We put the code for timing a test in a test fixture called // We put the code for timing a test in a test fixture called
// "QuickTest". QuickTest is intended to be the super fixture that // "QuickTest". QuickTest is intended to be the super fixture that
// other fixtures derive from, therefore there is no test case with // other fixtures derive from, therefore there is no test case with
// the name "QuickTest". This is OK. // the name "QuickTest". This is OK.
// //
skipping to change at line 164 skipping to change at line 165
// } // }
Queue<int> q0_; Queue<int> q0_;
Queue<int> q1_; Queue<int> q1_;
Queue<int> q2_; Queue<int> q2_;
}; };
// Now, let's write tests using the QueueTest fixture. // Now, let's write tests using the QueueTest fixture.
// Tests the default constructor. // Tests the default constructor.
TEST_F(QueueTest, DefaultConstructor) { TEST_F(QueueTest, DefaultConstructor) { EXPECT_EQ(0u, q0_.Size()); }
EXPECT_EQ(0u, q0_.Size());
}
// Tests Dequeue(). // Tests Dequeue().
TEST_F(QueueTest, Dequeue) { TEST_F(QueueTest, Dequeue) {
int* n = q0_.Dequeue(); int* n = q0_.Dequeue();
EXPECT_TRUE(n == nullptr); EXPECT_TRUE(n == nullptr);
n = q1_.Dequeue(); n = q1_.Dequeue();
EXPECT_TRUE(n != nullptr); EXPECT_TRUE(n != nullptr);
EXPECT_EQ(1, *n); EXPECT_EQ(1, *n);
EXPECT_EQ(0u, q1_.Size()); EXPECT_EQ(0u, q1_.Size());
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)