Index: ext/googletest/googletest/samples/sample7_unittest.cc =================================================================== diff -u -N -r4a481bbe77043e0bda2435c6d62a02700b3e46c5 -r2e4eacb299f21d06196fe13140b4b0d095abdca9 --- ext/googletest/googletest/samples/sample7_unittest.cc (.../sample7_unittest.cc) (revision 4a481bbe77043e0bda2435c6d62a02700b3e46c5) +++ ext/googletest/googletest/samples/sample7_unittest.cc (.../sample7_unittest.cc) (revision 2e4eacb299f21d06196fe13140b4b0d095abdca9) @@ -26,9 +26,8 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: vladl@google.com (Vlad Losev) + // This sample shows how to test common properties of multiple // implementations of an interface (aka interface tests) using // value-parameterized tests. Each test in the test case has @@ -39,9 +38,8 @@ #include "prime_tables.h" #include "gtest/gtest.h" +namespace { -#if GTEST_HAS_PARAM_TEST - using ::testing::TestWithParam; using ::testing::Values; @@ -65,9 +63,9 @@ // 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 { +class PrimeTableTestSmpl7 : public TestWithParam { public: - virtual ~PrimeTableTest() { delete table_; } + virtual ~PrimeTableTestSmpl7() { delete table_; } virtual void SetUp() { table_ = (*GetParam())(); } virtual void TearDown() { delete table_; @@ -78,7 +76,7 @@ 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 +85,7 @@ 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 +94,7 @@ 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,19 +110,8 @@ // // 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 - -// Google Test may not support value-parameterized tests with some -// compilers. If we use conditional compilation to compile out all -// code referring to the gtest_main library, MSVC linker will not link -// that library at all and consequently complain about missing entry -// point defined in that library (fatal error LNK1561: entry point -// must be defined). This dummy test keeps gtest_main linked in. -TEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {} - -#endif // GTEST_HAS_PARAM_TEST +} // namespace