diff options
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-death-test-test.cc | 8 | ||||
-rw-r--r-- | googletest/test/googletest-output-test-golden-lin.txt | 6 | ||||
-rw-r--r-- | googletest/test/googletest-output-test_.cc | 2 | ||||
-rw-r--r-- | googletest/test/googletest-param-test-test.cc | 33 | ||||
-rw-r--r-- | googletest/test/googletest-port-test.cc | 18 | ||||
-rwxr-xr-x | googletest/test/googletest-throw-on-failure-test.py | 2 | ||||
-rw-r--r-- | googletest/test/gtest_environment_test.cc | 2 | ||||
-rw-r--r-- | googletest/test/gtest_pred_impl_unittest.cc | 20 | ||||
-rw-r--r-- | googletest/test/gtest_premature_exit_test.cc | 4 | ||||
-rwxr-xr-x | googletest/test/gtest_test_utils.py | 7 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 68 |
11 files changed, 74 insertions, 96 deletions
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index 814d771..cba906c 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -141,7 +141,7 @@ class TestForDeathTest : public testing::Test { DieInside("MemberFunction"); } - // True if MemberFunction() should die. + // True if and only if MemberFunction() should die. bool should_die_; const FilePath original_dir_; }; @@ -158,7 +158,7 @@ class MayDie { } private: - // True if MemberFunction() should die. + // True if and only if MemberFunction() should die. bool should_die_; }; @@ -573,8 +573,8 @@ TEST_F(TestForDeathTest, ErrorMessageMismatch) { }, "died but not with expected error"); } -// On exit, *aborted will be true if the EXPECT_DEATH() statement -// aborted the function. +// On exit, *aborted will be true if and only if the EXPECT_DEATH() +// statement aborted the function. void ExpectDeathTestHelper(bool* aborted) { *aborted = true; EXPECT_DEATH(DieIf(false), "DieIf"); // This assertion should fail. diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt index 038de92..de777cf 100644 --- a/googletest/test/googletest-output-test-golden-lin.txt +++ b/googletest/test/googletest-output-test-golden-lin.txt @@ -966,9 +966,9 @@ Expected equality of these values: Stack trace: (omitted) [0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2 -[0;32m[----------] [m1 test from EmptyBasenameParamInst -[0;32m[ RUN ] [mEmptyBasenameParamInst.Passes/0 -[0;32m[ OK ] [mEmptyBasenameParamInst.Passes/0 +[0;32m[----------] [m1 test from All/EmptyBasenameParamInst +[0;32m[ RUN ] [mAll/EmptyBasenameParamInst.Passes/0 +[0;32m[ OK ] [mAll/EmptyBasenameParamInst.Passes/0 [0;32m[----------] [m2 tests from PrintingStrings/ParamTest [0;32m[ RUN ] [mPrintingStrings/ParamTest.Success/a [0;32m[ OK ] [mPrintingStrings/ParamTest.Success/a diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 4f716d8..8de2bd1 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -102,7 +102,7 @@ class EmptyBasenameParamInst : public testing::TestWithParam<int> {}; TEST_P(EmptyBasenameParamInst, Passes) { EXPECT_EQ(1, GetParam()); } -INSTANTIATE_TEST_SUITE_P(, EmptyBasenameParamInst, testing::Values(1)); +INSTANTIATE_TEST_SUITE_P(All, EmptyBasenameParamInst, testing::Values(1)); static const char kGoldenString[] = "\"Line\0 1\"\nLine 2"; diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index 6c187df..2740aaa 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -37,6 +37,7 @@ # include <algorithm> # include <iostream> # include <list> +# include <set> # include <sstream> # include <string> # include <vector> @@ -802,7 +803,7 @@ TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) { ::testing::UnitTest::GetInstance()->current_test_info(); EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_suite_name()); - EXPECT_STREQ("FooSomeTestName", test_info->name()); + EXPECT_STREQ("FooSomeTestName/0", test_info->name()); } INSTANTIATE_TEST_SUITE_P(FortyTwo, MacroNamingTest, Values(42)); @@ -819,6 +820,36 @@ TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized), EXPECT_STREQ("FooSomeTestName", test_info->name()); } +TEST(MacroNameing, LookupNames) { + std::set<std::string> know_suite_names, know_test_names; + + auto ins = testing::UnitTest::GetInstance(); + int ts = 0; + while (const testing::TestSuite* suite = ins->GetTestSuite(ts++)) { + know_suite_names.insert(suite->name()); + + int ti = 0; + while (const testing::TestInfo* info = suite->GetTestInfo(ti++)) { + know_test_names.insert(std::string(suite->name()) + "." + info->name()); + } + } + + // Check that the expected form of the test suit name actualy exists. + EXPECT_NE( // + know_suite_names.find("FortyTwo/MacroNamingTest"), + know_suite_names.end()); + EXPECT_NE( + know_suite_names.find("MacroNamingTestNonParametrized"), + know_suite_names.end()); + // Check that the expected form of the test name actualy exists. + EXPECT_NE( // + know_test_names.find("FortyTwo/MacroNamingTest.FooSomeTestName/0"), + know_test_names.end()); + EXPECT_NE( + know_test_names.find("MacroNamingTestNonParametrized.FooSomeTestName"), + know_test_names.end()); +} + // Tests that user supplied custom parameter names are working correctly. // Runs the test with a builtin helper method which uses PrintToString, // as well as a custom function and custom functor to ensure all possible diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 42035cc..60d637c 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -201,24 +201,6 @@ TEST(ImplicitCastTest, CanUseImplicitConstructor) { EXPECT_TRUE(converted); } -TEST(IteratorTraitsTest, WorksForSTLContainerIterators) { - StaticAssertTypeEq<int, - IteratorTraits< ::std::vector<int>::const_iterator>::value_type>(); - StaticAssertTypeEq<bool, - IteratorTraits< ::std::list<bool>::iterator>::value_type>(); -} - -TEST(IteratorTraitsTest, WorksForPointerToNonConst) { - StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>(); - StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>(); -} - -TEST(IteratorTraitsTest, WorksForPointerToConst) { - StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>(); - StaticAssertTypeEq<const void*, - IteratorTraits<const void* const*>::value_type>(); -} - TEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) { if (AlwaysFalse()) GTEST_CHECK_(false) << "This should never be executed; " diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py index a38cd33..ea627c4 100755 --- a/googletest/test/googletest-throw-on-failure-test.py +++ b/googletest/test/googletest-throw-on-failure-test.py @@ -86,7 +86,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): variable; None if the variable should be unset. flag_value: value of the --gtest_break_on_failure flag; None if the flag should not be present. - should_fail: True if the program is expected to fail. + should_fail: True if and only if the program is expected to fail. """ SetEnvVar(THROW_ON_FAILURE, env_var_value) diff --git a/googletest/test/gtest_environment_test.cc b/googletest/test/gtest_environment_test.cc index 58908e6..064bfc5 100644 --- a/googletest/test/gtest_environment_test.cc +++ b/googletest/test/gtest_environment_test.cc @@ -116,7 +116,7 @@ void Check(bool condition, const char* msg) { } } -// Runs the tests. Return true if successful. +// Runs the tests. Return true if and only if successful. // // The 'failure' parameter specifies the type of failure that should // be generated by the global set-up. diff --git a/googletest/test/gtest_pred_impl_unittest.cc b/googletest/test/gtest_pred_impl_unittest.cc index 4d77896..1afe5e2 100644 --- a/googletest/test/gtest_pred_impl_unittest.cc +++ b/googletest/test/gtest_pred_impl_unittest.cc @@ -144,10 +144,10 @@ class Predicate1Test : public testing::Test { } } - // true if the test function is expected to run to finish. + // true if and only if the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true if and only if the test function did run to finish. static bool finished_; static int n1_; @@ -539,10 +539,10 @@ class Predicate2Test : public testing::Test { } } - // true if the test function is expected to run to finish. + // true if and only if the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true if and only if the test function did run to finish. static bool finished_; static int n1_; @@ -976,10 +976,10 @@ class Predicate3Test : public testing::Test { } } - // true if the test function is expected to run to finish. + // true if and only if the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true if and only if the test function did run to finish. static bool finished_; static int n1_; @@ -1455,10 +1455,10 @@ class Predicate4Test : public testing::Test { } } - // true if the test function is expected to run to finish. + // true if and only if the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true if and only if the test function did run to finish. static bool finished_; static int n1_; @@ -1976,10 +1976,10 @@ class Predicate5Test : public testing::Test { } } - // true if the test function is expected to run to finish. + // true if and only if the test function is expected to run to finish. static bool expected_to_finish_; - // true if the test function did run to finish. + // true if and only if the test function did run to finish. static bool finished_; static int n1_; diff --git a/googletest/test/gtest_premature_exit_test.cc b/googletest/test/gtest_premature_exit_test.cc index 777a8bf..1d1187e 100644 --- a/googletest/test/gtest_premature_exit_test.cc +++ b/googletest/test/gtest_premature_exit_test.cc @@ -45,7 +45,7 @@ namespace { class PrematureExitTest : public Test { public: - // Returns true if the given file exists. + // Returns true if and only if the given file exists. static bool FileExists(const char* filepath) { StatStruct stat; return Stat(filepath, &stat) == 0; @@ -61,7 +61,7 @@ class PrematureExitTest : public Test { } } - // Returns true if the premature-exit file exists. + // Returns true if and only if the premature-exit file exists. bool PrematureExitFileExists() const { return FileExists(premature_exit_file_path_); } diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py index abd56ec..ef9363c 100755 --- a/googletest/test/gtest_test_utils.py +++ b/googletest/test/gtest_test_utils.py @@ -215,10 +215,11 @@ class Subprocess: Returns: An object that represents outcome of the executed process. It has the following attributes: - terminated_by_signal True if the child process has been terminated - by a signal. + terminated_by_signal True if and only if the child process has been + terminated by a signal. signal Sygnal that terminated the child process. - exited True if the child process exited normally. + exited True if and only if the child process exited + normally. exit_code The code with which the child process exited. output Child process's stdout and stderr output combined in a string. diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 5020d73..8312bd1 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -233,7 +233,6 @@ using testing::internal::AppendUserMessage; using testing::internal::ArrayAwareFind; using testing::internal::ArrayEq; using testing::internal::CodePointToUtf8; -using testing::internal::CompileAssertTypesEqual; using testing::internal::CopyArray; using testing::internal::CountIf; using testing::internal::EqFailure; @@ -262,7 +261,6 @@ using testing::internal::OsStackTraceGetterInterface; using testing::internal::ParseInt32Flag; using testing::internal::RelationToSourceCopy; using testing::internal::RelationToSourceReference; -using testing::internal::RemoveReference; using testing::internal::ShouldRunTestOnShard; using testing::internal::ShouldShard; using testing::internal::ShouldUseColor; @@ -2169,12 +2167,12 @@ static Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ = // First, some predicates and predicate-formatters needed by the tests. -// Returns true if the argument is an even number. +// Returns true if and only if the argument is an even number. bool IsEven(int n) { return (n % 2) == 0; } -// A functor that returns true if the argument is an even number. +// A functor that returns true if and only if the argument is an even number. struct IsEvenFunctor { bool operator()(int n) { return IsEven(n); } }; @@ -2218,13 +2216,13 @@ struct AssertIsEvenFunctor { } }; -// Returns true if the sum of the arguments is an even number. +// Returns true if and only if the sum of the arguments is an even number. bool SumIsEven2(int n1, int n2) { return IsEven(n1 + n2); } -// A functor that returns true if the sum of the arguments is an even -// number. +// A functor that returns true if and only if the sum of the arguments is an +// even number. struct SumIsEven3Functor { bool operator()(int n1, int n2, int n3) { return IsEven(n1 + n2 + n3); @@ -5345,7 +5343,7 @@ TEST_P(CodeLocationForTESTP, Verify) { VERIFY_CODE_LOCATION; } -INSTANTIATE_TEST_SUITE_P(, CodeLocationForTESTP, Values(0)); +INSTANTIATE_TEST_SUITE_P(All, CodeLocationForTESTP, Values(0)); template <typename T> class CodeLocationForTYPEDTEST : public Test { @@ -7103,42 +7101,12 @@ TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) { EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value); } -// Tests that CompileAssertTypesEqual compiles when the type arguments are -// equal. -TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) { - CompileAssertTypesEqual<void, void>(); - CompileAssertTypesEqual<int*, int*>(); -} - -// Tests that RemoveReference does not affect non-reference types. -TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) { - CompileAssertTypesEqual<int, RemoveReference<int>::type>(); - CompileAssertTypesEqual<const char, RemoveReference<const char>::type>(); -} - -// Tests that RemoveReference removes reference from reference types. -TEST(RemoveReferenceTest, RemovesReference) { - CompileAssertTypesEqual<int, RemoveReference<int&>::type>(); - CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>(); -} - -// Tests GTEST_REMOVE_REFERENCE_. - -template <typename T1, typename T2> -void TestGTestRemoveReference() { - CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_(T2)>(); -} - -TEST(RemoveReferenceTest, MacroVersion) { - TestGTestRemoveReference<int, int>(); - TestGTestRemoveReference<const char, const char&>(); -} - // Tests GTEST_REMOVE_REFERENCE_AND_CONST_. template <typename T1, typename T2> void TestGTestRemoveReferenceAndConst() { - CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>(); + static_assert(std::is_same<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>::value, + "GTEST_REMOVE_REFERENCE_AND_CONST_ failed."); } TEST(RemoveReferenceToConstTest, Works) { @@ -7153,7 +7121,8 @@ TEST(RemoveReferenceToConstTest, Works) { template <typename T1, typename T2> void TestGTestReferenceToConst() { - CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>(); + static_assert(std::is_same<T1, GTEST_REFERENCE_TO_CONST_(T2)>::value, + "GTEST_REFERENCE_TO_CONST_ failed."); } TEST(GTestReferenceToConstTest, Works) { @@ -7384,20 +7353,15 @@ TEST(IndexSequence, MakeIndexSequence) { // ElemFromList TEST(ElemFromList, Basic) { using testing::internal::ElemFromList; - using Idx = testing::internal::MakeIndexSequence<3>::type; - EXPECT_TRUE(( - std::is_same<int, ElemFromList<0, Idx, int, double, char>::type>::value)); EXPECT_TRUE( - (std::is_same<double, - ElemFromList<1, Idx, int, double, char>::type>::value)); + (std::is_same<int, ElemFromList<0, int, double, char>::type>::value)); EXPECT_TRUE( - (std::is_same<char, - ElemFromList<2, Idx, int, double, char>::type>::value)); + (std::is_same<double, ElemFromList<1, int, double, char>::type>::value)); EXPECT_TRUE( - (std::is_same< - char, ElemFromList<7, testing::internal::MakeIndexSequence<12>::type, - int, int, int, int, int, int, int, char, int, int, - int, int>::type>::value)); + (std::is_same<char, ElemFromList<2, int, double, char>::type>::value)); + EXPECT_TRUE(( + std::is_same<char, ElemFromList<7, int, int, int, int, int, int, int, + char, int, int, int, int>::type>::value)); } // FlatTuple |