Unverified Commit 0ffa5f97 authored by Chris Johnson's avatar Chris Johnson Committed by GitHub
Browse files

Merge branch 'master' into chore/fix_library_json

parents 0c0ca903 3880b13e
......@@ -12,7 +12,7 @@ Expected equality of these values:
3
Stack trace: (omitted)
[==========] Running 76 tests from 34 test cases.
[==========] Running 83 tests from 38 test suites.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
......@@ -392,26 +392,26 @@ Stack trace: (omitted)
[ RUN ] MixedUpTestCaseTest.ThisShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test case must use the same test fixture
class. However, in test case MixedUpTestCaseTest,
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTestCaseTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFail
using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation
units and have the same name. You should probably rename one
of the classes to put the tests into different test cases.
of the classes to put the tests into different test suites.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFail
[ RUN ] MixedUpTestCaseTest.ThisShouldFailToo
gtest.cc:#: Failure
Failed
All tests in the same test case must use the same test fixture
class. However, in test case MixedUpTestCaseTest,
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTestCaseTest,
you defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo
using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation
units and have the same name. You should probably rename one
of the classes to put the tests into different test cases.
of the classes to put the tests into different test suites.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseTest.ThisShouldFailToo
......@@ -421,13 +421,13 @@ Stack trace: (omitted)
[ RUN ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test case must use the same test fixture
class. However, in test case MixedUpTestCaseWithSameTestNameTest,
All tests in the same test suite must use the same test fixture
class. However, in test suite MixedUpTestCaseWithSameTestNameTest,
you defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail
using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation
units and have the same name. You should probably rename one
of the classes to put the tests into different test cases.
of the classes to put the tests into different test suites.
Stack trace: (omitted)
[ FAILED ] MixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
......@@ -437,9 +437,9 @@ Stack trace: (omitted)
[ RUN ] TEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test case must use the same test fixture
class, so mixing TEST_F and TEST in the same test case is
illegal. In test case TEST_F_before_TEST_in_same_test_case,
All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test suite is
illegal. In test suite TEST_F_before_TEST_in_same_test_case,
test DefinedUsingTEST_F is defined using TEST_F but
test DefinedUsingTESTAndShouldFail is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
......@@ -453,9 +453,9 @@ Stack trace: (omitted)
[ RUN ] TEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
gtest.cc:#: Failure
Failed
All tests in the same test case must use the same test fixture
class, so mixing TEST_F and TEST in the same test case is
illegal. In test case TEST_before_TEST_F_in_same_test_case,
All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test suite is
illegal. In test suite TEST_before_TEST_F_in_same_test_case,
test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but
test DefinedUsingTEST is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
......@@ -870,6 +870,84 @@ Expected non-fatal failure.
Stack trace: (omitted)
[ FAILED ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[----------] 2 tests from DynamicFixture
DynamicFixture::SetUpTestCase
[ RUN ] DynamicFixture.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[ OK ] DynamicFixture.DynamicTestPass
[ RUN ] DynamicFixture.DynamicTestFail
DynamicFixture()
DynamicFixture::SetUp
googletest-output-test_.cc:#: Failure
Value of: Pass
Actual: false
Expected: true
Stack trace: (omitted)
DynamicFixture::TearDown
~DynamicFixture()
[ FAILED ] DynamicFixture.DynamicTestFail
DynamicFixture::TearDownTestCase
[----------] 1 test from DynamicFixtureAnotherName
DynamicFixture::SetUpTestCase
[ RUN ] DynamicFixtureAnotherName.DynamicTestPass
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[ OK ] DynamicFixtureAnotherName.DynamicTestPass
DynamicFixture::TearDownTestCase
[----------] 2 tests from BadDynamicFixture1
DynamicFixture::SetUpTestCase
[ RUN ] BadDynamicFixture1.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[ OK ] BadDynamicFixture1.FixtureBase
[ RUN ] BadDynamicFixture1.TestBase
DynamicFixture()
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class, so mixing TEST_F and TEST in the same test suite is
illegal. In test suite BadDynamicFixture1,
test FixtureBase is defined using TEST_F but
test TestBase is defined using TEST. You probably
want to change the TEST to TEST_F or move it to another test
case.
Stack trace: (omitted)
~DynamicFixture()
[ FAILED ] BadDynamicFixture1.TestBase
DynamicFixture::TearDownTestCase
[----------] 2 tests from BadDynamicFixture2
DynamicFixture::SetUpTestCase
[ RUN ] BadDynamicFixture2.FixtureBase
DynamicFixture()
DynamicFixture::SetUp
DynamicFixture::TearDown
~DynamicFixture()
[ OK ] BadDynamicFixture2.FixtureBase
[ RUN ] BadDynamicFixture2.Derived
DynamicFixture()
gtest.cc:#: Failure
Failed
All tests in the same test suite must use the same test fixture
class. However, in test suite BadDynamicFixture2,
you defined test FixtureBase and test Derived
using two different test fixture classes. This can happen if
the two classes are from different namespaces or translation
units and have the same name. You should probably rename one
of the classes to put the tests into different test suites.
Stack trace: (omitted)
~DynamicFixture()
[ FAILED ] BadDynamicFixture2.Derived
DynamicFixture::TearDownTestCase
[----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
......@@ -906,9 +984,9 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
[==========] 76 tests from 34 test cases ran.
[ PASSED ] 26 tests.
[ FAILED ] 50 tests, listed below:
[==========] 83 tests from 38 test suites ran.
[ PASSED ] 30 tests.
[ FAILED ] 53 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ FAILED ] NonfatalFailureTest.DiffForLongStrings
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
......@@ -957,14 +1035,17 @@ Stack trace: (omitted)
[ FAILED ] ExpectFailureWithThreadsTest.ExpectFatalFailure
[ FAILED ] ExpectFailureWithThreadsTest.ExpectNonFatalFailure
[ FAILED ] ScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread
[ FAILED ] DynamicFixture.DynamicTestFail
[ FAILED ] BadDynamicFixture1.TestBase
[ FAILED ] BadDynamicFixture2.Derived
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
50 FAILED TESTS
53 FAILED TESTS
 YOU HAVE 1 DISABLED TEST
Note: Google Test filter = FatalFailureTest.*:LoggingTest.*
[==========] Running 4 tests from 2 test cases.
[==========] Running 4 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from FatalFailureTest
[ RUN ] FatalFailureTest.FatalFailureInSubroutine
......@@ -1017,7 +1098,7 @@ Stack trace: (omitted)
[----------] 1 test from LoggingTest (? ms total)
[----------] Global test environment tear-down
[==========] 4 tests from 2 test cases ran. (? ms total)
[==========] 4 tests from 2 test suites ran. (? ms total)
[ PASSED ] 0 tests.
[ FAILED ] 4 tests, listed below:
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
......@@ -1027,21 +1108,21 @@ Stack trace: (omitted)
4 FAILED TESTS
Note: Google Test filter = *DISABLED_*
[==========] Running 1 test from 1 test case.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from DisabledTestsWarningTest
[ RUN ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[ OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran.
[==========] 1 test from 1 test suite ran.
[ PASSED ] 1 test.
Note: Google Test filter = PassingTest.*
Note: This is test shard 2 of 2.
[==========] Running 1 test from 1 test case.
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from PassingTest
[ RUN ] PassingTest.PassingTest2
[ OK ] PassingTest.PassingTest2
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran.
[==========] 1 test from 1 test suite ran.
[ PASSED ] 1 test.
......@@ -55,7 +55,6 @@ NO_STACKTRACE_SUPPORT_FLAG = '--no_stacktrace_support'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_WINDOWS = os.name == 'nt'
# FIXME: remove the _lin suffix.
GOLDEN_NAME = 'googletest-output-test-golden-lin.txt'
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('googletest-output-test_')
......
......@@ -1024,6 +1024,56 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {
"Some other non-fatal failure.");
}
class DynamicFixture : public testing::Test {
protected:
DynamicFixture() { printf("DynamicFixture()\n"); }
~DynamicFixture() override { printf("~DynamicFixture()\n"); }
void SetUp() override { printf("DynamicFixture::SetUp\n"); }
void TearDown() override { printf("DynamicFixture::TearDown\n"); }
static void SetUpTestCase() { printf("DynamicFixture::SetUpTestCase\n"); }
static void TearDownTestCase() {
printf("DynamicFixture::TearDownTestCase\n");
}
};
template <bool Pass>
class DynamicTest : public DynamicFixture {
public:
void TestBody() override { EXPECT_TRUE(Pass); }
};
auto dynamic_test = (
// Register two tests with the same fixture correctly.
testing::RegisterTest(
"DynamicFixture", "DynamicTestPass", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
testing::RegisterTest(
"DynamicFixture", "DynamicTestFail", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<false>; }),
// Register the same fixture with another name. That's fine.
testing::RegisterTest(
"DynamicFixtureAnotherName", "DynamicTestPass", nullptr, nullptr,
__FILE__, __LINE__,
[]() -> DynamicFixture* { return new DynamicTest<true>; }),
// Register two tests with the same fixture incorrectly.
testing::RegisterTest(
"BadDynamicFixture1", "FixtureBase", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
testing::RegisterTest(
"BadDynamicFixture1", "TestBase", nullptr, nullptr, __FILE__, __LINE__,
[]() -> testing::Test* { return new DynamicTest<true>; }),
// Register two tests with the same fixture incorrectly by ommiting the
// return type.
testing::RegisterTest(
"BadDynamicFixture2", "FixtureBase", nullptr, nullptr, __FILE__,
__LINE__, []() -> DynamicFixture* { return new DynamicTest<true>; }),
testing::RegisterTest("BadDynamicFixture2", "Derived", nullptr, nullptr,
__FILE__, __LINE__,
[]() { return new DynamicTest<true>; }));
// Two test environments for testing testing::AddGlobalTestEnvironment().
......
......@@ -37,29 +37,20 @@
#include <string.h>
#include <algorithm>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "gtest/gtest-printers.h"
#include "gtest/gtest.h"
#if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map> // NOLINT
#endif // GTEST_HAS_UNORDERED_MAP_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set> // NOLINT
#endif // GTEST_HAS_UNORDERED_SET_
#if GTEST_HAS_STD_FORWARD_LIST_
# include <forward_list> // NOLINT
#endif // GTEST_HAS_STD_FORWARD_LIST_
// Some user-defined types for testing the universal value printer.
// An anonymous enum type.
......@@ -192,8 +183,14 @@ class PathLike {
public:
struct iterator {
typedef PathLike value_type;
iterator& operator++();
PathLike& operator*();
};
using value_type = char;
using const_iterator = iterator;
PathLike() {}
iterator begin() const { return iterator(); }
......@@ -814,7 +811,6 @@ TEST(PrintStlContainerTest, NonEmptyDeque) {
EXPECT_EQ("{ 1, 3 }", Print(non_empty));
}
#if GTEST_HAS_UNORDERED_MAP_
TEST(PrintStlContainerTest, OneElementHashMap) {
::std::unordered_map<int, char> map1;
......@@ -834,9 +830,7 @@ TEST(PrintStlContainerTest, HashMultiMap) {
<< " where Print(map1) returns \"" << result << "\".";
}
#endif // GTEST_HAS_UNORDERED_MAP_
#if GTEST_HAS_UNORDERED_SET_
TEST(PrintStlContainerTest, HashSet) {
::std::unordered_set<int> set1;
......@@ -873,7 +867,6 @@ TEST(PrintStlContainerTest, HashMultiSet) {
EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin()));
}
#endif // GTEST_HAS_UNORDERED_SET_
TEST(PrintStlContainerTest, List) {
const std::string a[] = {"hello", "world"};
......@@ -915,14 +908,12 @@ TEST(PrintStlContainerTest, MultiSet) {
EXPECT_EQ("{ 1, 1, 1, 2, 5 }", Print(set1));
}
#if GTEST_HAS_STD_FORWARD_LIST_
TEST(PrintStlContainerTest, SinglyLinkedList) {
int a[] = { 9, 2, 8 };
const std::forward_list<int> ints(a, a + 3);
EXPECT_EQ("{ 9, 2, 8 }", Print(ints));
}
#endif // GTEST_HAS_STD_FORWARD_LIST_
TEST(PrintStlContainerTest, Pair) {
pair<const bool, int> p(true, 5);
......
......@@ -227,6 +227,4 @@ TEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {
EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(1), "");
}
// FIXME: Add a test for the class HasNewFatalFailureHelper.
} // namespace
......@@ -73,8 +73,7 @@ def Run(command):
return p.exited and p.exit_code == 0
# The tests. FIXME: refactor the class to share common
# logic with code in googletest-break-on-failure-unittest.py.
# The tests.
class ThrowOnFailureTest(gtest_test_utils.TestCase):
"""Tests the throw-on-failure mode."""
......
......@@ -249,7 +249,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {
TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {
EXPECT_DEATH_IF_SUPPORTED(
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C, D"),
"foo\\.cc.1.?: No test named D can be found in this test case\\.");
"foo\\.cc.1.?: No test named D can be found in this test suite\\.");
}
TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
......@@ -264,7 +264,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C");
EXPECT_DEATH_IF_SUPPORTED(
state_.AddTestName("foo.cc", 2, "FooTest", "D"),
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P"
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_SUITE_P"
"\\(FooTest, \\.\\.\\.\\)\\.");
}
......
......@@ -96,7 +96,6 @@ TEST(Test, Test) {
int kTestForContinuingTest = 0;
TEST(Test, Test2) {
// FIXME: how to force Test2 to be after Test?
kTestForContinuingTest = 1;
}
......
......@@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file is AUTOMATICALLY GENERATED on 01/02/2018 by command
// This file is AUTOMATICALLY GENERATED on 01/02/2019 by command
// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
// Regression test for gtest_pred_impl.h
......
......@@ -117,7 +117,6 @@ const int kNumberOfParamTests = 10;
class MyParamTest : public testing::TestWithParam<int> {};
TEST_P(MyParamTest, ShouldPass) {
// FIXME: Make parameter value checking robust WRT order of tests.
GTEST_CHECK_INT_EQ_(g_param_test_count % kNumberOfParamTests, GetParam());
g_param_test_count++;
}
......
......@@ -307,8 +307,6 @@ def Main():
_ParseAndStripGTestFlags(sys.argv)
# The tested binaries should not be writing XML output files unless the
# script explicitly instructs them to.
# FIXME: Move this into Subprocess when we implement
# passing environment into it as a parameter.
if GTEST_OUTPUT_VAR_NAME in os.environ:
del os.environ[GTEST_OUTPUT_VAR_NAME]
......
......@@ -511,8 +511,6 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
EXPECT_EQ("1970-01-01T00:00:00", FormatEpochTimeInMillisAsIso8601(0));
}
#if GTEST_CAN_COMPARE_NULL
# ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
# pragma option push -w-ccc -w-rch
......@@ -541,7 +539,6 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) {
# pragma option pop
# endif
#endif // GTEST_CAN_COMPARE_NULL
//
// Tests CodePointToUtf8().
......@@ -586,7 +583,7 @@ TEST(CodePointToUtf8Test, CanEncode12To16Bits) {
#if !GTEST_WIDE_STRING_USES_UTF16_
// Tests in this group require a wchar_t to hold > 16 bits, and thus
// are skipped on Windows, Cygwin, and Symbian, where a wchar_t is
// are skipped on Windows, and Cygwin, where a wchar_t is
// 16-bit wide. This code may not compile on those systems.
// Tests that Unicode code-points that have 17 to 21 bits are encoded
......@@ -2360,6 +2357,16 @@ TEST(PredTest, SingleEvaluationOnFailure) {
EXPECT_EQ(1, n4) << "Argument 4 is not evaluated exactly once.";
}
// Test predicate assertions for sets
TEST(PredTest, ExpectPredEvalFailure) {
std::set<int> set_a = {2, 1, 3, 4, 5};
std::set<int> set_b = {0, 4, 8};
const auto compare_sets = [] (std::set<int>, std::set<int>) { return false; };
EXPECT_NONFATAL_FAILURE(
EXPECT_PRED2(compare_sets, set_a, set_b),
"compare_sets(set_a, set_b) evaluates to false, where\nset_a evaluates "
"to { 1, 2, 3, 4, 5 }\nset_b evaluates to { 0, 4, 8 }");
}
// Some helper functions for testing using overloaded/template
// functions with ASSERT_PREDn and EXPECT_PREDn.
......@@ -2822,8 +2829,6 @@ TEST_F(FloatTest, LargeDiff) {
TEST_F(FloatTest, Infinity) {
EXPECT_FLOAT_EQ(values_.infinity, values_.close_to_infinity);
EXPECT_FLOAT_EQ(-values_.infinity, -values_.close_to_infinity);
#if !GTEST_OS_SYMBIAN
// Nokia's STLport crashes if we try to output infinity or NaN.
EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, -values_.infinity),
"-values_.infinity");
......@@ -2831,14 +2836,10 @@ TEST_F(FloatTest, Infinity) {
// are only 1 DLP apart.
EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, values_.nan1),
"values_.nan1");
#endif // !GTEST_OS_SYMBIAN
}
// Tests that comparing with NAN always returns false.
TEST_F(FloatTest, NaN) {
#if !GTEST_OS_SYMBIAN
// Nokia's STLport crashes if we try to output infinity or NaN.
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
......@@ -2856,7 +2857,6 @@ TEST_F(FloatTest, NaN) {
EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(v.nan1, v.infinity),
"v.infinity");
#endif // !GTEST_OS_SYMBIAN
}
// Tests that *_FLOAT_EQ are reflexive.
......@@ -2918,10 +2918,6 @@ TEST_F(FloatTest, FloatLEFails) {
EXPECT_PRED_FORMAT2(FloatLE, values_.further_from_one, 1.0f);
}, "(values_.further_from_one) <= (1.0f)");
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
// Nokia's STLport crashes if we try to output infinity or NaN.
// C++Builder gives bad results for ordered comparisons involving NaNs
// due to compiler bugs.
EXPECT_NONFATAL_FAILURE({ // NOLINT
EXPECT_PRED_FORMAT2(FloatLE, values_.nan1, values_.infinity);
}, "(values_.nan1) <= (values_.infinity)");
......@@ -2931,7 +2927,6 @@ TEST_F(FloatTest, FloatLEFails) {
EXPECT_FATAL_FAILURE({ // NOLINT
ASSERT_PRED_FORMAT2(FloatLE, values_.nan1, values_.nan1);
}, "(values_.nan1) <= (values_.nan1)");
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
}
// Instantiates FloatingPointTest for testing *_DOUBLE_EQ.
......@@ -2995,8 +2990,6 @@ TEST_F(DoubleTest, LargeDiff) {
TEST_F(DoubleTest, Infinity) {
EXPECT_DOUBLE_EQ(values_.infinity, values_.close_to_infinity);
EXPECT_DOUBLE_EQ(-values_.infinity, -values_.close_to_infinity);
#if !GTEST_OS_SYMBIAN
// Nokia's STLport crashes if we try to output infinity or NaN.
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, -values_.infinity),
"-values_.infinity");
......@@ -3004,18 +2997,10 @@ TEST_F(DoubleTest, Infinity) {
// are only 1 DLP apart.
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, values_.nan1),
"values_.nan1");
#endif // !GTEST_OS_SYMBIAN
}
// Tests that comparing with NAN always returns false.
TEST_F(DoubleTest, NaN) {
#if !GTEST_OS_SYMBIAN
// In C++Builder, names within local classes (such as used by
// EXPECT_FATAL_FAILURE) cannot be resolved against static members of the
// scoping class. Use a static local alias as a workaround.
// We use the assignment syntax since some compilers, like Sun Studio,
// don't allow initializing references using construction syntax
// (parentheses).
static const DoubleTest::TestValues& v = this->values_;
// Nokia's STLport crashes if we try to output infinity or NaN.
......@@ -3025,17 +3010,13 @@ TEST_F(DoubleTest, NaN) {
EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, v.nan1), "v.nan1");
EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(v.nan1, v.infinity),
"v.infinity");
#endif // !GTEST_OS_SYMBIAN
}
// Tests that *_DOUBLE_EQ are reflexive.
TEST_F(DoubleTest, Reflexive) {
EXPECT_DOUBLE_EQ(0.0, 0.0);
EXPECT_DOUBLE_EQ(1.0, 1.0);
#if !GTEST_OS_SYMBIAN
// Nokia's STLport crashes if we try to output infinity or NaN.
ASSERT_DOUBLE_EQ(values_.infinity, values_.infinity);
#endif // !GTEST_OS_SYMBIAN
}
// Tests that *_DOUBLE_EQ are commutative.
......@@ -3090,10 +3071,6 @@ TEST_F(DoubleTest, DoubleLEFails) {
EXPECT_PRED_FORMAT2(DoubleLE, values_.further_from_one, 1.0);
}, "(values_.further_from_one) <= (1.0)");
#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
// Nokia's STLport crashes if we try to output infinity or NaN.
// C++Builder gives bad results for ordered comparisons involving NaNs
// due to compiler bugs.
EXPECT_NONFATAL_FAILURE({ // NOLINT
EXPECT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.infinity);
}, "(values_.nan1) <= (values_.infinity)");
......@@ -3103,7 +3080,6 @@ TEST_F(DoubleTest, DoubleLEFails) {
EXPECT_FATAL_FAILURE({ // NOLINT
ASSERT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.nan1);
}, "(values_.nan1) <= (values_.nan1)");
#endif // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)
}
......@@ -3711,7 +3687,6 @@ TEST(AssertionTest, ASSERT_EQ) {
}
// Tests ASSERT_EQ(NULL, pointer).
#if GTEST_CAN_COMPARE_NULL
TEST(AssertionTest, ASSERT_EQ_NULL) {
// A success.
const char* p = nullptr;
......@@ -3725,7 +3700,6 @@ TEST(AssertionTest, ASSERT_EQ_NULL) {
static int n = 0;
EXPECT_FATAL_FAILURE(ASSERT_EQ(nullptr, &n), " &n\n Which is:");
}
#endif // GTEST_CAN_COMPARE_NULL
// Tests ASSERT_EQ(0, non_pointer). Since the literal 0 can be
// treated as a null pointer by the compiler, we need to make sure
......@@ -3916,11 +3890,8 @@ TEST(AssertionTest, NamedEnum) {
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), "Which is: 1");
}
// The version of gcc used in XCode 2.2 has a bug and doesn't allow
// anonymous enums in assertions. Therefore the following test is not
// done on Mac.
// Sun Studio and HP aCC also reject this code.
#if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC)
// Sun Studio and HP aCC2reject this code.
#if !defined(__SUNPRO_CC) && !defined(__HP_aCC)
// Tests using assertions with anonymous enums.
enum {
......@@ -4439,7 +4410,6 @@ TEST(ExpectTest, EXPECT_EQ_Double) {
"5.1");
}
#if GTEST_CAN_COMPARE_NULL
// Tests EXPECT_EQ(NULL, pointer).
TEST(ExpectTest, EXPECT_EQ_NULL) {
// A success.
......@@ -4454,7 +4424,6 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
int n = 0;
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(nullptr, &n), " &n\n Which is:");
}
#endif // GTEST_CAN_COMPARE_NULL
// Tests EXPECT_EQ(0, non_pointer). Since the literal 0 can be
// treated as a null pointer by the compiler, we need to make sure
......@@ -5472,6 +5441,67 @@ TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ("123", shared_resource_);
}
// Tests SetupTestSuite/TearDown TestSuite API
class SetUpTestSuiteTest : public Test {
protected:
// This will be called once before the first test in this test case
// is run.
static void SetUpTestSuite() {
printf("Setting up the test suite . . .\n");
// Initializes some shared resource. In this simple example, we
// just create a C string. More complex stuff can be done if
// desired.
shared_resource_ = "123";
// Increments the number of test cases that have been set up.
counter_++;
// SetUpTestSuite() should be called only once.
EXPECT_EQ(1, counter_);
}
// This will be called once after the last test in this test case is
// run.
static void TearDownTestSuite() {
printf("Tearing down the test suite . . .\n");
// Decrements the number of test suites that have been set up.
counter_--;
// TearDownTestSuite() should be called only once.
EXPECT_EQ(0, counter_);
// Cleans up the shared resource.
shared_resource_ = nullptr;
}
// This will be called before each test in this test case.
void SetUp() override {
// SetUpTestSuite() should be called only once, so counter_ should
// always be 1.
EXPECT_EQ(1, counter_);
}
// Number of test suites that have been set up.
static int counter_;
// Some resource to be shared by all tests in this test case.
static const char* shared_resource_;
};
int SetUpTestSuiteTest::counter_ = 0;
const char* SetUpTestSuiteTest::shared_resource_ = nullptr;
// A test that uses the shared resource.
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite1) {
EXPECT_STRNE(nullptr, shared_resource_);
}
// Another test that uses the shared resource.
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite2) {
EXPECT_STREQ("123", shared_resource_);
}
// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
......@@ -7054,7 +7084,6 @@ GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST.
// Tests for internal utilities necessary for implementation of the universal
// printing.
// FIXME: Find a better home for them.
class ConversionHelperBase {};
class ConversionHelperDerived : public ConversionHelperBase {};
......@@ -7547,3 +7576,30 @@ TEST_F(AdHocTestResultTest, AdHocTestResultTestForUnitTestDoesNotShowFailure) {
testing::UnitTest::GetInstance()->ad_hoc_test_result();
EXPECT_FALSE(test_result.Failed());
}
class DynamicUnitTestFixture : public testing::Test {};
class DynamicTest : public DynamicUnitTestFixture {
void TestBody() override { EXPECT_TRUE(true); }
};
auto* dynamic_test = testing::RegisterTest(
"DynamicUnitTestFixture", "DynamicTest", "TYPE", "VALUE", __FILE__,
__LINE__, []() -> DynamicUnitTestFixture* { return new DynamicTest; });
TEST(RegisterTest, WasRegistered) {
auto* unittest = testing::UnitTest::GetInstance();
for (int i = 0; i < unittest->total_test_case_count(); ++i) {
auto* tests = unittest->GetTestCase(i);
if (tests->name() != std::string("DynamicUnitTestFixture")) continue;
for (int j = 0; j < tests->total_test_count(); ++j) {
if (tests->GetTestInfo(j)->name() != std::string("DynamicTest")) continue;
// Found it.
EXPECT_STREQ(tests->GetTestInfo(j)->value_param(), "VALUE");
EXPECT_STREQ(tests->GetTestInfo(j)->type_param(), "TYPE");
return;
}
}
FAIL() << "Didn't find the test!";
}
......@@ -111,11 +111,6 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
self.assert_(p.exited)
self.assertEquals(0, p.exit_code)
# FIXME: libtool causes the built test binary to be
# named lt-gtest_xml_outfiles_test_ instead of
# gtest_xml_outfiles_test_. To account for this possibility, we
# allow both names in the following code. We should remove this
# when libtool replacement tool is ready.
output_file_name1 = test_name + ".xml"
output_file1 = os.path.join(self.output_dir_, output_file_name1)
output_file_name2 = 'lt-' + output_file_name1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment