diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-08-30 02:57:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 02:57:12 (GMT) |
commit | b8e2562086ef326a4a88089f85b29ce7b6f9464b (patch) | |
tree | fe224846be47cb3240729c7b967a11d211ce707c /googletest/test/googletest-output-test_.cc | |
parent | 3dbba3b072b1e67c5dc6793741da4b5408f8a552 (diff) | |
parent | 9ad739833e16daa0f2909da7daee19a9dd608f29 (diff) | |
download | googletest-b8e2562086ef326a4a88089f85b29ce7b6f9464b.zip googletest-b8e2562086ef326a4a88089f85b29ce7b6f9464b.tar.gz googletest-b8e2562086ef326a4a88089f85b29ce7b6f9464b.tar.bz2 |
Merge pull request #1790 from google/9A681768AABE08D1EFA5CA77528236A4
Googletest export
Diffstat (limited to 'googletest/test/googletest-output-test_.cc')
-rw-r--r-- | googletest/test/googletest-output-test_.cc | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 3860cf4..180630e 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -39,6 +39,10 @@ #include <stdlib.h> +#if _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */) +#endif // . _MSC_VER + #if GTEST_IS_THREADSAFE using testing::ScopedFakeTestPartResultReporter; using testing::TestPartResultArray; @@ -801,6 +805,28 @@ TYPED_TEST(TypedTest, Failure) { EXPECT_EQ(1, TypeParam()) << "Expected failure"; } +typedef testing::Types<char, int> TypesForTestWithNames; + +template <typename T> +class TypedTestWithNames : public testing::Test {}; + +class TypedTestNames { + public: + template <typename T> + static std::string GetName(int i) { + if (testing::internal::IsSame<T, char>::value) + return std::string("char_") + ::testing::PrintToString(i); + if (testing::internal::IsSame<T, int>::value) + return std::string("int_") + ::testing::PrintToString(i); + } +}; + +TYPED_TEST_CASE(TypedTestWithNames, TypesForTestWithNames, TypedTestNames); + +TYPED_TEST(TypedTestWithNames, Success) {} + +TYPED_TEST(TypedTestWithNames, Failure) { FAIL(); } + #endif // GTEST_HAS_TYPED_TEST // This #ifdef block tests the output of type-parameterized tests. @@ -825,6 +851,22 @@ REGISTER_TYPED_TEST_CASE_P(TypedTestP, Success, Failure); typedef testing::Types<unsigned char, unsigned int> UnsignedTypes; INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes); +class TypedTestPNames { + public: + template <typename T> + static std::string GetName(int i) { + if (testing::internal::IsSame<T, unsigned char>::value) { + return std::string("unsigned_char_") + ::testing::PrintToString(i); + } + if (testing::internal::IsSame<T, unsigned int>::value) { + return std::string("unsigned_int_") + ::testing::PrintToString(i); + } + } +}; + +INSTANTIATE_TYPED_TEST_CASE_P(UnsignedCustomName, TypedTestP, UnsignedTypes, + TypedTestPNames); + #endif // GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_DEATH_TEST @@ -1060,6 +1102,8 @@ int main(int argc, char **argv) { // are registered, and torn down in the reverse order. testing::AddGlobalTestEnvironment(new FooEnvironment); testing::AddGlobalTestEnvironment(new BarEnvironment); - +#if _MSC_VER + GTEST_DISABLE_MSC_WARNINGS_POP_() // 4127 +#endif // . _MSC_VER return RunAllTests(); } |