Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
0599a7b8
Commit
0599a7b8
authored
Jan 11, 2019
by
misterg
Committed by
Gennadiy Civil
Jan 11, 2019
Browse files
Googletest export
Change tests to use new Test Suite API PiperOrigin-RevId: 228908894
parent
2edadced
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
87 deletions
+92
-87
googletest/test/gtest_repeat_test.cc
googletest/test/gtest_repeat_test.cc
+3
-3
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+69
-66
googletest/test/gtest_xml_output_unittest.py
googletest/test/gtest_xml_output_unittest.py
+6
-6
googletest/test/gtest_xml_output_unittest_.cc
googletest/test/gtest_xml_output_unittest_.cc
+14
-12
No files found.
googletest/test/gtest_repeat_test.cc
View file @
0599a7b8
...
@@ -120,9 +120,9 @@ TEST_P(MyParamTest, ShouldPass) {
...
@@ -120,9 +120,9 @@ TEST_P(MyParamTest, ShouldPass) {
GTEST_CHECK_INT_EQ_
(
g_param_test_count
%
kNumberOfParamTests
,
GetParam
());
GTEST_CHECK_INT_EQ_
(
g_param_test_count
%
kNumberOfParamTests
,
GetParam
());
g_param_test_count
++
;
g_param_test_count
++
;
}
}
INSTANTIATE_TEST_
CAS
E_P
(
MyParamSequence
,
INSTANTIATE_TEST_
SUIT
E_P
(
MyParamSequence
,
MyParamTest
,
MyParamTest
,
testing
::
Range
(
0
,
kNumberOfParamTests
));
testing
::
Range
(
0
,
kNumberOfParamTests
));
// Resets the count for each test.
// Resets the count for each test.
void
ResetCounts
()
{
void
ResetCounts
()
{
...
...
googletest/test/gtest_unittest.cc
View file @
0599a7b8
...
@@ -1570,7 +1570,7 @@ class GTestFlagSaverTest : public Test {
...
@@ -1570,7 +1570,7 @@ class GTestFlagSaverTest : public Test {
// Saves the Google Test flags such that we can restore them later, and
// Saves the Google Test flags such that we can restore them later, and
// then sets them to their default values. This will be called
// then sets them to their default values. This will be called
// before the first test in this test case is run.
// before the first test in this test case is run.
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
saver_
=
new
GTestFlagSaver
;
saver_
=
new
GTestFlagSaver
;
GTEST_FLAG
(
also_run_disabled_tests
)
=
false
;
GTEST_FLAG
(
also_run_disabled_tests
)
=
false
;
...
@@ -1592,7 +1592,7 @@ class GTestFlagSaverTest : public Test {
...
@@ -1592,7 +1592,7 @@ class GTestFlagSaverTest : public Test {
// Restores the Google Test flags that the tests have modified. This will
// Restores the Google Test flags that the tests have modified. This will
// be called after the last test in this test case is run.
// be called after the last test in this test case is run.
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
delete
saver_
;
delete
saver_
;
saver_
=
nullptr
;
saver_
=
nullptr
;
}
}
...
@@ -1956,7 +1956,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {
...
@@ -1956,7 +1956,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {
// Test class, there are no separate tests for the following classes
// Test class, there are no separate tests for the following classes
// (except for some trivial cases):
// (except for some trivial cases):
//
//
// Test
Cas
e, UnitTest, UnitTestResultPrinter.
// Test
Suit
e, UnitTest, UnitTestResultPrinter.
//
//
// Similarly, there are no separate tests for the following macros:
// Similarly, there are no separate tests for the following macros:
//
//
...
@@ -1990,7 +1990,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
...
@@ -1990,7 +1990,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
key
);
key
);
}
}
void
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
void
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
const
char
*
key
)
{
const
char
*
key
)
{
const
TestCase
*
test_case
=
UnitTest
::
GetInstance
()
->
current_test_case
();
const
TestCase
*
test_case
=
UnitTest
::
GetInstance
()
->
current_test_case
();
ASSERT_TRUE
(
test_case
!=
nullptr
);
ASSERT_TRUE
(
test_case
!=
nullptr
);
...
@@ -1998,7 +1998,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
...
@@ -1998,7 +1998,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
test_case
->
ad_hoc_test_result
(),
key
);
test_case
->
ad_hoc_test_result
(),
key
);
}
}
void
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
void
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
const
char
*
key
)
{
const
char
*
key
)
{
ExpectNonFatalFailureRecordingPropertyWithReservedKey
(
ExpectNonFatalFailureRecordingPropertyWithReservedKey
(
UnitTest
::
GetInstance
()
->
ad_hoc_test_result
(),
key
);
UnitTest
::
GetInstance
()
->
ad_hoc_test_result
(),
key
);
...
@@ -2010,29 +2010,30 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
...
@@ -2010,29 +2010,30 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(
class
UnitTestRecordPropertyTest
:
class
UnitTestRecordPropertyTest
:
public
testing
::
internal
::
UnitTestRecordPropertyTestHelper
{
public
testing
::
internal
::
UnitTestRecordPropertyTestHelper
{
public:
public:
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"disabled"
);
"disabled"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"errors"
);
"errors"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"failures"
);
"failures"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"name"
);
"name"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"tests"
);
"tests"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
Suit
e
(
"time"
);
"time"
);
Test
::
RecordProperty
(
"test_case_key_1"
,
"1"
);
Test
::
RecordProperty
(
"test_case_key_1"
,
"1"
);
const
TestCase
*
test_case
=
UnitTest
::
GetInstance
()
->
current_test_case
();
const
testing
::
TestSuite
*
test_suite
=
ASSERT_TRUE
(
test_case
!=
nullptr
);
UnitTest
::
GetInstance
()
->
current_test_case
();
ASSERT_TRUE
(
test_suite
!=
nullptr
);
ASSERT_EQ
(
1
,
test_
cas
e
->
ad_hoc_test_result
().
test_property_count
());
ASSERT_EQ
(
1
,
test_
suit
e
->
ad_hoc_test_result
().
test_property_count
());
EXPECT_STREQ
(
"test_case_key_1"
,
EXPECT_STREQ
(
"test_case_key_1"
,
test_
cas
e
->
ad_hoc_test_result
().
GetTestProperty
(
0
).
key
());
test_
suit
e
->
ad_hoc_test_result
().
GetTestProperty
(
0
).
key
());
EXPECT_STREQ
(
"1"
,
EXPECT_STREQ
(
"1"
,
test_
cas
e
->
ad_hoc_test_result
().
GetTestProperty
(
0
).
value
());
test_
suit
e
->
ad_hoc_test_result
().
GetTestProperty
(
0
).
value
());
}
}
};
};
...
@@ -2085,7 +2086,7 @@ TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {
...
@@ -2085,7 +2086,7 @@ TEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {
}
}
TEST_F
(
UnitTestRecordPropertyTest
,
TEST_F
(
UnitTestRecordPropertyTest
,
AddFailureInsideTestsWhenUsingTest
Cas
eReservedKeys
)
{
AddFailureInsideTestsWhenUsingTest
Suit
eReservedKeys
)
{
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
(
"name"
);
"name"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest
(
...
@@ -2111,21 +2112,21 @@ TEST_F(UnitTestRecordPropertyTest,
...
@@ -2111,21 +2112,21 @@ TEST_F(UnitTestRecordPropertyTest,
class
UnitTestRecordPropertyTestEnvironment
:
public
Environment
{
class
UnitTestRecordPropertyTestEnvironment
:
public
Environment
{
public:
public:
void
TearDown
()
override
{
void
TearDown
()
override
{
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"tests"
);
"tests"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"failures"
);
"failures"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"disabled"
);
"disabled"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"errors"
);
"errors"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"name"
);
"name"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"timestamp"
);
"timestamp"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"time"
);
"time"
);
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Cas
e
(
ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTest
Suit
e
(
"random_seed"
);
"random_seed"
);
}
}
};
};
...
@@ -3119,28 +3120,28 @@ TEST(DisabledTest, NotDISABLED_TestShouldRun) {
...
@@ -3119,28 +3120,28 @@ TEST(DisabledTest, NotDISABLED_TestShouldRun) {
// A test case whose name starts with DISABLED_.
// A test case whose name starts with DISABLED_.
// Should not run.
// Should not run.
TEST
(
DISABLED_Test
Cas
e
,
TestShouldNotRun
)
{
TEST
(
DISABLED_Test
Suit
e
,
TestShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: Test in disabled test case should not be run."
;
FAIL
()
<<
"Unexpected failure: Test in disabled test case should not be run."
;
}
}
// A test case and test whose names start with DISABLED_.
// A test case and test whose names start with DISABLED_.
// Should not run.
// Should not run.
TEST
(
DISABLED_Test
Cas
e
,
DISABLED_TestShouldNotRun
)
{
TEST
(
DISABLED_Test
Suit
e
,
DISABLED_TestShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: Test in disabled test case should not be run."
;
FAIL
()
<<
"Unexpected failure: Test in disabled test case should not be run."
;
}
}
// Check that when all tests in a test case are disabled, SetUpTest
Cas
e() and
// Check that when all tests in a test case are disabled, SetUpTest
Suit
e() and
// TearDownTest
Cas
e() are not called.
// TearDownTest
Suit
e() are not called.
class
DisabledTestsTest
:
public
Test
{
class
DisabledTestsTest
:
public
Test
{
protected:
protected:
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
FAIL
()
<<
"Unexpected failure: All tests disabled in test case. "
FAIL
()
<<
"Unexpected failure: All tests disabled in test case. "
"SetUpTest
Cas
e() should not be called."
;
"SetUpTest
Suit
e() should not be called."
;
}
}
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
FAIL
()
<<
"Unexpected failure: All tests disabled in test case. "
FAIL
()
<<
"Unexpected failure: All tests disabled in test case. "
"TearDownTest
Cas
e() should not be called."
;
"TearDownTest
Suit
e() should not be called."
;
}
}
};
};
...
@@ -3161,7 +3162,7 @@ class TypedTest : public Test {
...
@@ -3161,7 +3162,7 @@ class TypedTest : public Test {
};
};
typedef
testing
::
Types
<
int
,
double
>
NumericTypes
;
typedef
testing
::
Types
<
int
,
double
>
NumericTypes
;
TYPED_TEST_
CAS
E
(
TypedTest
,
NumericTypes
);
TYPED_TEST_
SUIT
E
(
TypedTest
,
NumericTypes
);
TYPED_TEST
(
TypedTest
,
DISABLED_ShouldNotRun
)
{
TYPED_TEST
(
TypedTest
,
DISABLED_ShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: Disabled typed test should not run."
;
FAIL
()
<<
"Unexpected failure: Disabled typed test should not run."
;
...
@@ -3171,7 +3172,7 @@ template <typename T>
...
@@ -3171,7 +3172,7 @@ template <typename T>
class
DISABLED_TypedTest
:
public
Test
{
class
DISABLED_TypedTest
:
public
Test
{
};
};
TYPED_TEST_
CAS
E
(
DISABLED_TypedTest
,
NumericTypes
);
TYPED_TEST_
SUIT
E
(
DISABLED_TypedTest
,
NumericTypes
);
TYPED_TEST
(
DISABLED_TypedTest
,
ShouldNotRun
)
{
TYPED_TEST
(
DISABLED_TypedTest
,
ShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: Disabled typed test should not run."
;
FAIL
()
<<
"Unexpected failure: Disabled typed test should not run."
;
...
@@ -3187,31 +3188,31 @@ template <typename T>
...
@@ -3187,31 +3188,31 @@ template <typename T>
class
TypedTestP
:
public
Test
{
class
TypedTestP
:
public
Test
{
};
};
TYPED_TEST_
CAS
E_P
(
TypedTestP
);
TYPED_TEST_
SUIT
E_P
(
TypedTestP
);
TYPED_TEST_P
(
TypedTestP
,
DISABLED_ShouldNotRun
)
{
TYPED_TEST_P
(
TypedTestP
,
DISABLED_ShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: "
FAIL
()
<<
"Unexpected failure: "
<<
"Disabled type-parameterized test should not run."
;
<<
"Disabled type-parameterized test should not run."
;
}
}
REGISTER_TYPED_TEST_
CAS
E_P
(
TypedTestP
,
DISABLED_ShouldNotRun
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
TypedTestP
,
DISABLED_ShouldNotRun
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
TypedTestP
,
NumericTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
TypedTestP
,
NumericTypes
);
template
<
typename
T
>
template
<
typename
T
>
class
DISABLED_TypedTestP
:
public
Test
{
class
DISABLED_TypedTestP
:
public
Test
{
};
};
TYPED_TEST_
CAS
E_P
(
DISABLED_TypedTestP
);
TYPED_TEST_
SUIT
E_P
(
DISABLED_TypedTestP
);
TYPED_TEST_P
(
DISABLED_TypedTestP
,
ShouldNotRun
)
{
TYPED_TEST_P
(
DISABLED_TypedTestP
,
ShouldNotRun
)
{
FAIL
()
<<
"Unexpected failure: "
FAIL
()
<<
"Unexpected failure: "
<<
"Disabled type-parameterized test should not run."
;
<<
"Disabled type-parameterized test should not run."
;
}
}
REGISTER_TYPED_TEST_
CAS
E_P
(
DISABLED_TypedTestP
,
ShouldNotRun
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
DISABLED_TypedTestP
,
ShouldNotRun
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
DISABLED_TypedTestP
,
NumericTypes
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
DISABLED_TypedTestP
,
NumericTypes
);
#endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_HAS_TYPED_TEST_P
...
@@ -3487,7 +3488,7 @@ std::vector<std::string> CharsToLines(const std::string& str) {
...
@@ -3487,7 +3488,7 @@ std::vector<std::string> CharsToLines(const std::string& str) {
return
out
;
return
out
;
}
}
TEST
(
EditDistance
,
Test
Cas
es
)
{
TEST
(
EditDistance
,
Test
Suit
es
)
{
struct
Case
{
struct
Case
{
int
line
;
int
line
;
const
char
*
left
;
const
char
*
left
;
...
@@ -5310,11 +5311,11 @@ namespace testing {
...
@@ -5310,11 +5311,11 @@ namespace testing {
class
TestInfoTest
:
public
Test
{
class
TestInfoTest
:
public
Test
{
protected:
protected:
static
const
TestInfo
*
GetTestInfo
(
const
char
*
test_name
)
{
static
const
TestInfo
*
GetTestInfo
(
const
char
*
test_name
)
{
const
Test
Cas
e
*
const
test_
cas
e
=
const
Test
Suit
e
*
const
test_
suit
e
=
GetUnitTestImpl
()
->
GetTest
Cas
e
(
"TestInfoTest"
,
""
,
nullptr
,
nullptr
);
GetUnitTestImpl
()
->
GetTest
Suit
e
(
"TestInfoTest"
,
""
,
nullptr
,
nullptr
);
for
(
int
i
=
0
;
i
<
test_
cas
e
->
total_test_count
();
++
i
)
{
for
(
int
i
=
0
;
i
<
test_
suit
e
->
total_test_count
();
++
i
)
{
const
TestInfo
*
const
test_info
=
test_
cas
e
->
GetTestInfo
(
i
);
const
TestInfo
*
const
test_info
=
test_
suit
e
->
GetTestInfo
(
i
);
if
(
strcmp
(
test_name
,
test_info
->
name
())
==
0
)
if
(
strcmp
(
test_name
,
test_info
->
name
())
==
0
)
return
test_info
;
return
test_info
;
}
}
...
@@ -5371,13 +5372,13 @@ TEST_P(CodeLocationForTESTP, Verify) {
...
@@ -5371,13 +5372,13 @@ TEST_P(CodeLocationForTESTP, Verify) {
VERIFY_CODE_LOCATION
;
VERIFY_CODE_LOCATION
;
}
}
INSTANTIATE_TEST_
CAS
E_P
(,
CodeLocationForTESTP
,
Values
(
0
));
INSTANTIATE_TEST_
SUIT
E_P
(,
CodeLocationForTESTP
,
Values
(
0
));
template
<
typename
T
>
template
<
typename
T
>
class
CodeLocationForTYPEDTEST
:
public
Test
{
class
CodeLocationForTYPEDTEST
:
public
Test
{
};
};
TYPED_TEST_
CAS
E
(
CodeLocationForTYPEDTEST
,
int
);
TYPED_TEST_
SUIT
E
(
CodeLocationForTYPEDTEST
,
int
);
TYPED_TEST
(
CodeLocationForTYPEDTEST
,
Verify
)
{
TYPED_TEST
(
CodeLocationForTYPEDTEST
,
Verify
)
{
VERIFY_CODE_LOCATION
;
VERIFY_CODE_LOCATION
;
...
@@ -5387,20 +5388,21 @@ template <typename T>
...
@@ -5387,20 +5388,21 @@ template <typename T>
class
CodeLocationForTYPEDTESTP
:
public
Test
{
class
CodeLocationForTYPEDTESTP
:
public
Test
{
};
};
TYPED_TEST_
CAS
E_P
(
CodeLocationForTYPEDTESTP
);
TYPED_TEST_
SUIT
E_P
(
CodeLocationForTYPEDTESTP
);
TYPED_TEST_P
(
CodeLocationForTYPEDTESTP
,
Verify
)
{
TYPED_TEST_P
(
CodeLocationForTYPEDTESTP
,
Verify
)
{
VERIFY_CODE_LOCATION
;
VERIFY_CODE_LOCATION
;
}
}
REGISTER_TYPED_TEST_
CAS
E_P
(
CodeLocationForTYPEDTESTP
,
Verify
);
REGISTER_TYPED_TEST_
SUIT
E_P
(
CodeLocationForTYPEDTESTP
,
Verify
);
INSTANTIATE_TYPED_TEST_
CAS
E_P
(
My
,
CodeLocationForTYPEDTESTP
,
int
);
INSTANTIATE_TYPED_TEST_
SUIT
E_P
(
My
,
CodeLocationForTYPEDTESTP
,
int
);
#undef VERIFY_CODE_LOCATION
#undef VERIFY_CODE_LOCATION
// Tests setting up and tearing down a test case.
// Tests setting up and tearing down a test case.
// Legacy API is deprecated but still available
#ifndef REMOVE_LEGACY_TEST_CASEAPI
class
SetUpTestCaseTest
:
public
Test
{
class
SetUpTestCaseTest
:
public
Test
{
protected:
protected:
// This will be called once before the first test in this test case
// This will be called once before the first test in this test case
...
@@ -5459,8 +5461,9 @@ TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); }
...
@@ -5459,8 +5461,9 @@ TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); }
TEST_F
(
SetUpTestCaseTest
,
Test2
)
{
TEST_F
(
SetUpTestCaseTest
,
Test2
)
{
EXPECT_STREQ
(
"123"
,
shared_resource_
);
EXPECT_STREQ
(
"123"
,
shared_resource_
);
}
}
#endif // REMOVE_LEGACY_TEST_CASEAPI
// Tests SetupTestSuite/TearDown TestSuite
API
// Tests SetupTestSuite/TearDown TestSuite
class
SetUpTestSuiteTest
:
public
Test
{
class
SetUpTestSuiteTest
:
public
Test
{
protected:
protected:
// This will be called once before the first test in this test case
// This will be called once before the first test in this test case
...
@@ -6278,7 +6281,7 @@ class CurrentTestInfoTest : public Test {
...
@@ -6278,7 +6281,7 @@ class CurrentTestInfoTest : public Test {
protected:
protected:
// Tests that current_test_info() returns NULL before the first test in
// Tests that current_test_info() returns NULL before the first test in
// the test case is run.
// the test case is run.
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
// There should be no tests running at this point.
// There should be no tests running at this point.
const
TestInfo
*
test_info
=
const
TestInfo
*
test_info
=
UnitTest
::
GetInstance
()
->
current_test_info
();
UnitTest
::
GetInstance
()
->
current_test_info
();
...
@@ -6288,7 +6291,7 @@ class CurrentTestInfoTest : public Test {
...
@@ -6288,7 +6291,7 @@ class CurrentTestInfoTest : public Test {
// Tests that current_test_info() returns NULL after the last test in
// Tests that current_test_info() returns NULL after the last test in
// the test case has run.
// the test case has run.
static
void
TearDownTest
Cas
e
()
{
static
void
TearDownTest
Suit
e
()
{
const
TestInfo
*
test_info
=
const
TestInfo
*
test_info
=
UnitTest
::
GetInstance
()
->
current_test_info
();
UnitTest
::
GetInstance
()
->
current_test_info
();
EXPECT_TRUE
(
test_info
==
nullptr
)
EXPECT_TRUE
(
test_info
==
nullptr
)
...
@@ -6298,14 +6301,14 @@ class CurrentTestInfoTest : public Test {
...
@@ -6298,14 +6301,14 @@ class CurrentTestInfoTest : public Test {
// Tests that current_test_info() returns TestInfo for currently running
// Tests that current_test_info() returns TestInfo for currently running
// test by checking the expected test name against the actual one.
// test by checking the expected test name against the actual one.
TEST_F
(
CurrentTestInfoTest
,
WorksForFirstTestInATest
Cas
e
)
{
TEST_F
(
CurrentTestInfoTest
,
WorksForFirstTestInATest
Suit
e
)
{
const
TestInfo
*
test_info
=
const
TestInfo
*
test_info
=
UnitTest
::
GetInstance
()
->
current_test_info
();
UnitTest
::
GetInstance
()
->
current_test_info
();
ASSERT_TRUE
(
nullptr
!=
test_info
)
ASSERT_TRUE
(
nullptr
!=
test_info
)
<<
"There is a test running so we should have a valid TestInfo."
;
<<
"There is a test running so we should have a valid TestInfo."
;
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_case_name
())
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_case_name
())
<<
"Expected the name of the currently running test case."
;
<<
"Expected the name of the currently running test case."
;
EXPECT_STREQ
(
"WorksForFirstTestInATest
Cas
e"
,
test_info
->
name
())
EXPECT_STREQ
(
"WorksForFirstTestInATest
Suit
e"
,
test_info
->
name
())
<<
"Expected the name of the currently running test."
;
<<
"Expected the name of the currently running test."
;
}
}
...
@@ -6313,14 +6316,14 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {
...
@@ -6313,14 +6316,14 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {
// test by checking the expected test name against the actual one. We
// test by checking the expected test name against the actual one. We
// use this test to see that the TestInfo object actually changed from
// use this test to see that the TestInfo object actually changed from
// the previous invocation.
// the previous invocation.
TEST_F
(
CurrentTestInfoTest
,
WorksForSecondTestInATest
Cas
e
)
{
TEST_F
(
CurrentTestInfoTest
,
WorksForSecondTestInATest
Suit
e
)
{
const
TestInfo
*
test_info
=
const
TestInfo
*
test_info
=
UnitTest
::
GetInstance
()
->
current_test_info
();
UnitTest
::
GetInstance
()
->
current_test_info
();
ASSERT_TRUE
(
nullptr
!=
test_info
)
ASSERT_TRUE
(
nullptr
!=
test_info
)
<<
"There is a test running so we should have a valid TestInfo."
;
<<
"There is a test running so we should have a valid TestInfo."
;
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_case_name
())
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_case_name
())
<<
"Expected the name of the currently running test case."
;
<<
"Expected the name of the currently running test case."
;
EXPECT_STREQ
(
"WorksForSecondTestInATest
Cas
e"
,
test_info
->
name
())
EXPECT_STREQ
(
"WorksForSecondTestInATest
Suit
e"
,
test_info
->
name
())
<<
"Expected the name of the currently running test."
;
<<
"Expected the name of the currently running test."
;
}
}
...
@@ -7549,14 +7552,14 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
...
@@ -7549,14 +7552,14 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {
class
AdHocTestResultTest
:
public
testing
::
Test
{
class
AdHocTestResultTest
:
public
testing
::
Test
{
protected:
protected:
static
void
SetUpTest
Cas
e
()
{
static
void
SetUpTest
Suit
e
()
{
FAIL
()
<<
"A failure happened inside SetUpTest
Cas
e()."
;
FAIL
()
<<
"A failure happened inside SetUpTest
Suit
e()."
;
}
}
};
};
TEST_F
(
AdHocTestResultTest
,
AdHocTestResultForTest
Cas
eShowsFailure
)
{
TEST_F
(
AdHocTestResultTest
,
AdHocTestResultForTest
Suit
eShowsFailure
)
{
const
testing
::
TestResult
&
test_result
=
testing
::
UnitTest
::
GetInstance
()
const
testing
::
TestResult
&
test_result
=
testing
::
UnitTest
::
GetInstance
()
->
current_test_
cas
e
()
->
current_test_
suit
e
()
->
ad_hoc_test_result
();
->
ad_hoc_test_result
();
EXPECT_TRUE
(
test_result
.
Failed
());
EXPECT_TRUE
(
test_result
.
Failed
());
}
}
...
@@ -7579,8 +7582,8 @@ auto* dynamic_test = testing::RegisterTest(
...
@@ -7579,8 +7582,8 @@ auto* dynamic_test = testing::RegisterTest(
TEST
(
RegisterTest
,
WasRegistered
)
{
TEST
(
RegisterTest
,
WasRegistered
)
{
auto
*
unittest
=
testing
::
UnitTest
::
GetInstance
();
auto
*
unittest
=
testing
::
UnitTest
::
GetInstance
();
for
(
int
i
=
0
;
i
<
unittest
->
total_test_
cas
e_count
();
++
i
)
{
for
(
int
i
=
0
;
i
<
unittest
->
total_test_
suit
e_count
();
++
i
)
{
auto
*
tests
=
unittest
->
GetTest
Cas
e
(
i
);
auto
*
tests
=
unittest
->
GetTest
Suit
e
(
i
);
if
(
tests
->
name
()
!=
std
::
string
(
"DynamicUnitTestFixture"
))
continue
;
if
(
tests
->
name
()
!=
std
::
string
(
"DynamicUnitTestFixture"
))
continue
;
for
(
int
j
=
0
;
j
<
tests
->
total_test_count
();
++
j
)
{
for
(
int
j
=
0
;
j
<
tests
->
total_test_count
();
++
j
)
{
if
(
tests
->
GetTestInfo
(
j
)
->
name
()
!=
std
::
string
(
"DynamicTest"
))
continue
;
if
(
tests
->
GetTestInfo
(
j
)
->
name
()
!=
std
::
string
(
"DynamicTest"
))
continue
;
...
...
googletest/test/gtest_xml_output_unittest.py
View file @
0599a7b8
...
@@ -111,7 +111,7 @@ Invalid characters in brackets []%(stack)s]]></failure>
...
@@ -111,7 +111,7 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="SkippedTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="SkippedTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Skipped" status="skipped" time="*" classname="SkippedTest"/>
<testcase name="Skipped" status="skipped" time="*" classname="SkippedTest"/>
</testsuite>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTest
Cas
e="yes" TearDownTest
Cas
e="aye">
<testsuite name="PropertyRecordingTest" tests="4" failures="0" disabled="0" errors="0" time="*" SetUpTest
Suit
e="yes" TearDownTest
Suit
e="aye">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest">
<testcase name="OneProperty" status="run" time="*" classname="PropertyRecordingTest">
<properties>
<properties>
<property name="key_1" value="1"/>
<property name="key_1" value="1"/>
...
@@ -164,11 +164,11 @@ Invalid characters in brackets []%(stack)s]]></failure>
...
@@ -164,11 +164,11 @@ Invalid characters in brackets []%(stack)s]]></failure>
<testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="TypedTest/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="TypedTest/1" />
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="TypedTest/1" />
</testsuite>
</testsuite>
<testsuite name="Single/TypeParameterizedTest
Cas
e/0" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="Single/TypeParameterizedTest
Suit
e/0" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTest
Cas
e/0" />
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTest
Suit
e/0" />
</testsuite>
</testsuite>
<testsuite name="Single/TypeParameterizedTest
Cas
e/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="Single/TypeParameterizedTest
Suit
e/1" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTest
Cas
e/1" />
<testcase name="HasTypeParamAttribute" type_param="*" status="run" time="*" classname="Single/TypeParameterizedTest
Suit
e/1" />
</testsuite>
</testsuite>
</testsuites>"""
%
{
'stack'
:
STACK_TRACE_TEMPLATE
}
</testsuites>"""
%
{
'stack'
:
STACK_TRACE_TEMPLATE
}
...
@@ -186,7 +186,7 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
...
@@ -186,7 +186,7 @@ EXPECTED_SHARDED_TEST_XML = """<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testsuite name="SuccessfulTest" tests="1" failures="0" disabled="0" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
<testcase name="Succeeds" status="run" time="*" classname="SuccessfulTest"/>
</testsuite>
</testsuite>
<testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" errors="0" time="*" SetUpTest
Cas
e="yes" TearDownTest
Cas
e="aye">
<testsuite name="PropertyRecordingTest" tests="1" failures="0" disabled="0" errors="0" time="*" SetUpTest
Suit
e="yes" TearDownTest
Suit
e="aye">
<testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest">
<testcase name="TwoValuesForOneKeyUsesLastValue" status="run" time="*" classname="PropertyRecordingTest">
<properties>
<properties>
<property name="key_1" value="2"/>
<property name="key_1" value="2"/>
...
...
googletest/test/gtest_xml_output_unittest_.cc
View file @
0599a7b8
...
@@ -101,8 +101,10 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) {
...
@@ -101,8 +101,10 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) {
class
PropertyRecordingTest
:
public
Test
{
class
PropertyRecordingTest
:
public
Test
{
public:
public:
static
void
SetUpTestCase
()
{
RecordProperty
(
"SetUpTestCase"
,
"yes"
);
}
static
void
SetUpTestSuite
()
{
RecordProperty
(
"SetUpTestSuite"
,
"yes"
);
}
static
void
TearDownTestCase
()
{
RecordProperty
(
"TearDownTestCase"
,
"aye"
);
}
static
void
TearDownTestSuite
()
{
RecordProperty
(
"TearDownTestSuite"
,
"aye"
);
}
};
};
TEST_F
(
PropertyRecordingTest
,
OneProperty
)
{
TEST_F
(
PropertyRecordingTest
,
OneProperty
)
{
...
@@ -150,28 +152,28 @@ TEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) {
...
@@ -150,28 +152,28 @@ TEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) {
class
ValueParamTest
:
public
TestWithParam
<
int
>
{};
class
ValueParamTest
:
public
TestWithParam
<
int
>
{};
TEST_P
(
ValueParamTest
,
HasValueParamAttribute
)
{}
TEST_P
(
ValueParamTest
,
HasValueParamAttribute
)
{}
TEST_P
(
ValueParamTest
,
AnotherTestThatHasValueParamAttribute
)
{}
TEST_P
(
ValueParamTest
,
AnotherTestThatHasValueParamAttribute
)
{}
INSTANTIATE_TEST_
CAS
E_P
(
Single
,
ValueParamTest
,
Values
(
33
,
42
));
INSTANTIATE_TEST_
SUIT
E_P
(
Single
,
ValueParamTest
,
Values
(
33
,
42
));
#if GTEST_HAS_TYPED_TEST
#if GTEST_HAS_TYPED_TEST
// Verifies that the type parameter name is output in the 'type_param'
// Verifies that the type parameter name is output in the 'type_param'
// XML attribute for typed tests.
// XML attribute for typed tests.
template
<
typename
T
>
class
TypedTest
:
public
Test
{};
template
<
typename
T
>
class
TypedTest
:
public
Test
{};
typedef
testing
::
Types
<
int
,
long
>
TypedTestTypes
;
typedef
testing
::
Types
<
int
,
long
>
TypedTestTypes
;
TYPED_TEST_
CAS
E
(
TypedTest
,
TypedTestTypes
);
TYPED_TEST_
SUIT
E
(
TypedTest
,
TypedTestTypes
);
TYPED_TEST
(
TypedTest
,
HasTypeParamAttribute
)
{}
TYPED_TEST
(
TypedTest
,
HasTypeParamAttribute
)
{}
#endif
#endif
#if GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
// Verifies that the type parameter name is output in the 'type_param'
// Verifies that the type parameter name is output in the 'type_param'
// XML attribute for type-parameterized tests.
// XML attribute for type-parameterized tests.
template
<
typename
T
>
class
TypeParameterizedTestCase
:
public
Test
{};
template
<
typename
T
>
TYPED_TEST_CASE_P
(
TypeParameterizedTest
Case
)
;
class
TypeParameterizedTest
Suite
:
public
Test
{}
;
TYPED_TEST_P
(
TypeParameterizedTest
Case
,
HasTypeParamAttribute
)
{}
TYPED_TEST_
SUITE_
P
(
TypeParameterizedTest
Suite
);
REGISTER_
TYPED_TEST_
CASE_
P
(
TypeParameterizedTest
Cas
e
,
HasTypeParamAttribute
)
;
TYPED_TEST_P
(
TypeParameterizedTest
Suit
e
,
HasTypeParamAttribute
)
{}
typedef
testing
::
Types
<
int
,
long
>
TypeParameterizedTest
C
as
e
Type
s
;
REGISTER_TYPED_TEST_SUITE_P
(
TypeParameterizedTest
Suite
,
H
asType
ParamAttribute
)
;
INSTANTIATE_TYPED_TEST_CASE_P
(
Single
,
typedef
testing
::
Types
<
int
,
long
>
TypeParameterizedTestSuiteTypes
;
// NOLINT
TypeParameterizedTest
Cas
e
,
INSTANTIATE_TYPED_TEST_SUITE_P
(
Single
,
TypeParameterizedTest
Suit
e
,
TypeParameterizedTest
Cas
eTypes
);
TypeParameterizedTest
Suit
eTypes
);
#endif
#endif
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment