diff options
author | misterg <misterg@google.com> | 2017-08-01 18:36:29 (GMT) |
---|---|---|
committer | misterg <misterg@google.com> | 2017-08-01 18:36:29 (GMT) |
commit | f63e2a14a21aa0528e692d2d5ce1d8e53dfa5742 (patch) | |
tree | 078a97b20ebfd5747a8fad597493cffa45ff1ee2 /googletest | |
parent | 7755e5d241d119f0cdecd83fe66feee0f66a35cb (diff) | |
download | googletest-f63e2a14a21aa0528e692d2d5ce1d8e53dfa5742.zip googletest-f63e2a14a21aa0528e692d2d5ce1d8e53dfa5742.tar.gz googletest-f63e2a14a21aa0528e692d2d5ce1d8e53dfa5742.tar.bz2 |
WIP
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/samples/sample10_unittest.cc | 3 | ||||
-rw-r--r-- | googletest/samples/sample1_unittest.cc | 9 | ||||
-rw-r--r-- | googletest/samples/sample2_unittest.cc | 3 | ||||
-rw-r--r-- | googletest/samples/sample3_unittest.cc | 8 | ||||
-rw-r--r-- | googletest/samples/sample4_unittest.cc | 3 | ||||
-rw-r--r-- | googletest/samples/sample5_unittest.cc | 4 | ||||
-rw-r--r-- | googletest/samples/sample6_unittest.cc | 3 | ||||
-rw-r--r-- | googletest/samples/sample7_unittest.cc | 20 | ||||
-rw-r--r-- | googletest/samples/sample8_unittest.cc | 3 | ||||
-rw-r--r-- | googletest/samples/sample9_unittest.cc | 3 |
10 files changed, 31 insertions, 28 deletions
diff --git a/googletest/samples/sample10_unittest.cc b/googletest/samples/sample10_unittest.cc index 0051cd5..6ddb24b 100644 --- a/googletest/samples/sample10_unittest.cc +++ b/googletest/samples/sample10_unittest.cc @@ -35,7 +35,7 @@ #include <stdlib.h> #include "gtest/gtest.h" - +namespace { using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; using ::testing::Test; @@ -142,3 +142,4 @@ int main(int argc, char **argv) { } return RUN_ALL_TESTS(); } +} // namespace
\ No newline at end of file diff --git a/googletest/samples/sample1_unittest.cc b/googletest/samples/sample1_unittest.cc index aefc4f1..861eff9 100644 --- a/googletest/samples/sample1_unittest.cc +++ b/googletest/samples/sample1_unittest.cc @@ -46,7 +46,7 @@ #include <limits.h> #include "sample1.h" #include "gtest/gtest.h" - +namespace { // Step 2. Use the TEST macro to define your tests. // @@ -72,7 +72,6 @@ // // </TechnicalDetails> - // Tests Factorial(). // Tests factorial of negative numbers. @@ -100,9 +99,7 @@ TEST(FactorialTest, Negative) { } // Tests factorial of 0. -TEST(FactorialTest, Zero) { - EXPECT_EQ(1, Factorial(0)); -} +TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); } // Tests factorial of positive numbers. TEST(FactorialTest, Positive) { @@ -112,7 +109,6 @@ TEST(FactorialTest, Positive) { EXPECT_EQ(40320, Factorial(8)); } - // Tests IsPrime() // Tests negative input. @@ -139,6 +135,7 @@ TEST(IsPrimeTest, Positive) { EXPECT_FALSE(IsPrime(6)); EXPECT_TRUE(IsPrime(23)); } +} // namespace // Step 3. Call RUN_ALL_TESTS() in main(). // diff --git a/googletest/samples/sample2_unittest.cc b/googletest/samples/sample2_unittest.cc index 4fa19b7..826f2d4 100644 --- a/googletest/samples/sample2_unittest.cc +++ b/googletest/samples/sample2_unittest.cc @@ -42,7 +42,7 @@ #include "sample2.h" #include "gtest/gtest.h" - +namespace { // In this example, we test the MyString class (a simple string). // Tests the default c'tor. @@ -107,3 +107,4 @@ TEST(MyString, Set) { s.Set(NULL); EXPECT_STREQ(NULL, s.c_string()); } +} // namespace
\ No newline at end of file diff --git a/googletest/samples/sample3_unittest.cc b/googletest/samples/sample3_unittest.cc index bf3877d..18da0b3 100644 --- a/googletest/samples/sample3_unittest.cc +++ b/googletest/samples/sample3_unittest.cc @@ -67,7 +67,7 @@ #include "gtest/gtest.h" // 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. @@ -120,13 +120,13 @@ 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); @@ -144,7 +144,7 @@ TEST_F(QueueTest, Dequeue) { } // Tests the Queue::Map() function. -TEST_F(QueueTest, Map) { +TEST_F(QueueTestSmpl3, Map) { MapTester(&q0_); MapTester(&q1_); MapTester(&q2_); diff --git a/googletest/samples/sample4_unittest.cc b/googletest/samples/sample4_unittest.cc index fa5afc7..2d13a8b 100644 --- a/googletest/samples/sample4_unittest.cc +++ b/googletest/samples/sample4_unittest.cc @@ -31,7 +31,7 @@ #include "gtest/gtest.h" #include "sample4.h" - +namespace { // Tests the Increment() method. TEST(Counter, Increment) { Counter c; @@ -43,3 +43,4 @@ TEST(Counter, Increment) { EXPECT_EQ(1, c.Increment()); EXPECT_EQ(2, c.Increment()); } +} // namespace
\ No newline at end of file diff --git a/googletest/samples/sample5_unittest.cc b/googletest/samples/sample5_unittest.cc index 43d8e57..3099930 100644 --- a/googletest/samples/sample5_unittest.cc +++ b/googletest/samples/sample5_unittest.cc @@ -49,7 +49,7 @@ #include "sample3-inl.h" #include "gtest/gtest.h" #include "sample1.h" - +namespace { // 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 // failure. @@ -191,7 +191,7 @@ TEST_F(QueueTest, Dequeue) { EXPECT_EQ(1u, q2_.Size()); delete n; } - +} // namespace // If necessary, you can derive further test fixtures from a derived // fixture itself. For example, you can derive another fixture from // QueueTest. Google Test imposes no limit on how deep the hierarchy diff --git a/googletest/samples/sample6_unittest.cc b/googletest/samples/sample6_unittest.cc index 8f2036a..7b603a2 100644 --- a/googletest/samples/sample6_unittest.cc +++ b/googletest/samples/sample6_unittest.cc @@ -36,7 +36,7 @@ #include "prime_tables.h" #include "gtest/gtest.h" - +namespace { // First, we define some factory functions for creating instances of // the implementations. You may be able to skip this step if all your // implementations can be constructed the same way. @@ -222,3 +222,4 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated, // Instance name PrimeTableImplementations); // Type list #endif // GTEST_HAS_TYPED_TEST_P +} // namespace
\ No newline at end of file diff --git a/googletest/samples/sample7_unittest.cc b/googletest/samples/sample7_unittest.cc index 1b651a2..44f534b 100644 --- a/googletest/samples/sample7_unittest.cc +++ b/googletest/samples/sample7_unittest.cc @@ -39,7 +39,7 @@ #include "prime_tables.h" #include "gtest/gtest.h" - +namespace { #if GTEST_HAS_PARAM_TEST using ::testing::TestWithParam; @@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() { // can refer to the test parameter by GetParam(). In this case, the test // parameter is a factory function which we call in fixture's SetUp() to // create and store an instance of PrimeTable. -class PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> { +class PrimeTableTestSmpl7 : public TestWithParam<CreatePrimeTableFunc*> { public: - virtual ~PrimeTableTest() { delete table_; } + virtual ~PrimeTableTestSmpl7() { delete table_; } virtual void SetUp() { table_ = (*GetParam())(); } virtual void TearDown() { delete table_; @@ -78,7 +78,7 @@ class PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> { PrimeTable* table_; }; -TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) { +TEST_P(PrimeTableTestSmpl7, ReturnsFalseForNonPrimes) { EXPECT_FALSE(table_->IsPrime(-5)); EXPECT_FALSE(table_->IsPrime(0)); EXPECT_FALSE(table_->IsPrime(1)); @@ -87,7 +87,7 @@ TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) { EXPECT_FALSE(table_->IsPrime(100)); } -TEST_P(PrimeTableTest, ReturnsTrueForPrimes) { +TEST_P(PrimeTableTestSmpl7, ReturnsTrueForPrimes) { EXPECT_TRUE(table_->IsPrime(2)); EXPECT_TRUE(table_->IsPrime(3)); EXPECT_TRUE(table_->IsPrime(5)); @@ -96,7 +96,7 @@ TEST_P(PrimeTableTest, ReturnsTrueForPrimes) { EXPECT_TRUE(table_->IsPrime(131)); } -TEST_P(PrimeTableTest, CanGetNextPrime) { +TEST_P(PrimeTableTestSmpl7, CanGetNextPrime) { EXPECT_EQ(2, table_->GetNextPrime(0)); EXPECT_EQ(3, table_->GetNextPrime(2)); EXPECT_EQ(5, table_->GetNextPrime(3)); @@ -112,10 +112,9 @@ TEST_P(PrimeTableTest, CanGetNextPrime) { // // Here, we instantiate our tests with a list of two PrimeTable object // factory functions: -INSTANTIATE_TEST_CASE_P( - OnTheFlyAndPreCalculated, - PrimeTableTest, - Values(&CreateOnTheFlyPrimeTable, &CreatePreCalculatedPrimeTable<1000>)); +INSTANTIATE_TEST_CASE_P(OnTheFlyAndPreCalculated, PrimeTableTestSmpl7, + Values(&CreateOnTheFlyPrimeTable, + &CreatePreCalculatedPrimeTable<1000>)); #else @@ -128,3 +127,4 @@ INSTANTIATE_TEST_CASE_P( TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {} #endif // GTEST_HAS_PARAM_TEST +}
\ No newline at end of file diff --git a/googletest/samples/sample8_unittest.cc b/googletest/samples/sample8_unittest.cc index 7274334..4ce9667 100644 --- a/googletest/samples/sample8_unittest.cc +++ b/googletest/samples/sample8_unittest.cc @@ -37,7 +37,7 @@ #include "prime_tables.h" #include "gtest/gtest.h" - +namespace { #if GTEST_HAS_COMBINE // Suppose we want to introduce a new, improved implementation of PrimeTable @@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters, TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {} #endif // GTEST_HAS_COMBINE +}
\ No newline at end of file diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc index b2e2079..87ddca7 100644 --- a/googletest/samples/sample9_unittest.cc +++ b/googletest/samples/sample9_unittest.cc @@ -35,7 +35,7 @@ #include <stdio.h> #include "gtest/gtest.h" - +namespace { using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; using ::testing::Test; @@ -158,3 +158,4 @@ int main(int argc, char **argv) { return ret_val; } +} // namespace
\ No newline at end of file |