Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
ce654c2f
Commit
ce654c2f
authored
Aug 07, 2020
by
Derek Mauro
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2972 from srz-zumix:fix/remove_legacy_testcase_api_
PiperOrigin-RevId: 325220934
parents
d0de618a
b612003c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
25 deletions
+37
-25
gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+12
-0
gtest.cc
googletest/src/gtest.cc
+8
-8
googletest-shuffle-test_.cc
googletest/test/googletest-shuffle-test_.cc
+1
-1
gtest-typed-test_test.cc
googletest/test/gtest-typed-test_test.cc
+4
-4
gtest_unittest.cc
googletest/test/gtest_unittest.cc
+12
-12
No files found.
googletest/include/gtest/internal/gtest-internal.h
View file @
ce654c2f
...
@@ -520,6 +520,7 @@ struct SuiteApiResolver : T {
...
@@ -520,6 +520,7 @@ struct SuiteApiResolver : T {
static
SetUpTearDownSuiteFuncType
GetSetUpCaseOrSuite
(
const
char
*
filename
,
static
SetUpTearDownSuiteFuncType
GetSetUpCaseOrSuite
(
const
char
*
filename
,
int
line_num
)
{
int
line_num
)
{
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
SetUpTearDownSuiteFuncType
test_case_fp
=
SetUpTearDownSuiteFuncType
test_case_fp
=
GetNotDefaultOrNull
(
&
T
::
SetUpTestCase
,
&
Test
::
SetUpTestCase
);
GetNotDefaultOrNull
(
&
T
::
SetUpTestCase
,
&
Test
::
SetUpTestCase
);
SetUpTearDownSuiteFuncType
test_suite_fp
=
SetUpTearDownSuiteFuncType
test_suite_fp
=
...
@@ -531,10 +532,16 @@ struct SuiteApiResolver : T {
...
@@ -531,10 +532,16 @@ struct SuiteApiResolver : T {
<<
filename
<<
":"
<<
line_num
;
<<
filename
<<
":"
<<
line_num
;
return
test_case_fp
!=
nullptr
?
test_case_fp
:
test_suite_fp
;
return
test_case_fp
!=
nullptr
?
test_case_fp
:
test_suite_fp
;
#else
(
void
)(
filename
);
(
void
)(
line_num
);
return
&
T
::
SetUpTestSuite
;
#endif
}
}
static
SetUpTearDownSuiteFuncType
GetTearDownCaseOrSuite
(
const
char
*
filename
,
static
SetUpTearDownSuiteFuncType
GetTearDownCaseOrSuite
(
const
char
*
filename
,
int
line_num
)
{
int
line_num
)
{
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
SetUpTearDownSuiteFuncType
test_case_fp
=
SetUpTearDownSuiteFuncType
test_case_fp
=
GetNotDefaultOrNull
(
&
T
::
TearDownTestCase
,
&
Test
::
TearDownTestCase
);
GetNotDefaultOrNull
(
&
T
::
TearDownTestCase
,
&
Test
::
TearDownTestCase
);
SetUpTearDownSuiteFuncType
test_suite_fp
=
SetUpTearDownSuiteFuncType
test_suite_fp
=
...
@@ -546,6 +553,11 @@ struct SuiteApiResolver : T {
...
@@ -546,6 +553,11 @@ struct SuiteApiResolver : T {
<<
filename
<<
":"
<<
line_num
;
<<
filename
<<
":"
<<
line_num
;
return
test_case_fp
!=
nullptr
?
test_case_fp
:
test_suite_fp
;
return
test_case_fp
!=
nullptr
?
test_case_fp
:
test_suite_fp
;
#else
(
void
)(
filename
);
(
void
)(
line_num
);
return
&
T
::
TearDownTestSuite
;
#endif
}
}
};
};
...
...
googletest/src/gtest.cc
View file @
ce654c2f
...
@@ -3007,9 +3007,9 @@ void TestSuite::Run() {
...
@@ -3007,9 +3007,9 @@ void TestSuite::Run() {
// Call both legacy and the new API
// Call both legacy and the new API
repeater
->
OnTestSuiteStart
(
*
this
);
repeater
->
OnTestSuiteStart
(
*
this
);
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
repeater
->
OnTestCaseStart
(
*
this
);
repeater
->
OnTestCaseStart
(
*
this
);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
internal
::
HandleExceptionsInMethodIfSupported
(
internal
::
HandleExceptionsInMethodIfSupported
(
...
@@ -3034,9 +3034,9 @@ void TestSuite::Run() {
...
@@ -3034,9 +3034,9 @@ void TestSuite::Run() {
// Call both legacy and the new API
// Call both legacy and the new API
repeater
->
OnTestSuiteEnd
(
*
this
);
repeater
->
OnTestSuiteEnd
(
*
this
);
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
repeater
->
OnTestCaseEnd
(
*
this
);
repeater
->
OnTestCaseEnd
(
*
this
);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
impl
->
set_current_test_suite
(
nullptr
);
impl
->
set_current_test_suite
(
nullptr
);
}
}
...
@@ -3053,9 +3053,9 @@ void TestSuite::Skip() {
...
@@ -3053,9 +3053,9 @@ void TestSuite::Skip() {
// Call both legacy and the new API
// Call both legacy and the new API
repeater
->
OnTestSuiteStart
(
*
this
);
repeater
->
OnTestSuiteStart
(
*
this
);
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
repeater
->
OnTestCaseStart
(
*
this
);
repeater
->
OnTestCaseStart
(
*
this
);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
for
(
int
i
=
0
;
i
<
total_test_count
();
i
++
)
{
for
(
int
i
=
0
;
i
<
total_test_count
();
i
++
)
{
GetMutableTestInfo
(
i
)
->
Skip
();
GetMutableTestInfo
(
i
)
->
Skip
();
...
@@ -3064,9 +3064,9 @@ void TestSuite::Skip() {
...
@@ -3064,9 +3064,9 @@ void TestSuite::Skip() {
// Call both legacy and the new API
// Call both legacy and the new API
repeater
->
OnTestSuiteEnd
(
*
this
);
repeater
->
OnTestSuiteEnd
(
*
this
);
// Legacy API is deprecated but still available
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
repeater
->
OnTestCaseEnd
(
*
this
);
repeater
->
OnTestCaseEnd
(
*
this
);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI
_
impl
->
set_current_test_suite
(
nullptr
);
impl
->
set_current_test_suite
(
nullptr
);
}
}
...
...
googletest/test/googletest-shuffle-test_.cc
View file @
ce654c2f
...
@@ -82,7 +82,7 @@ class TestNamePrinter : public EmptyTestEventListener {
...
@@ -82,7 +82,7 @@ class TestNamePrinter : public EmptyTestEventListener {
}
}
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
{
void
OnTestStart
(
const
TestInfo
&
test_info
)
override
{
printf
(
"%s.%s
\n
"
,
test_info
.
test_
cas
e_name
(),
test_info
.
name
());
printf
(
"%s.%s
\n
"
,
test_info
.
test_
suit
e_name
(),
test_info
.
name
());
}
}
};
};
...
...
googletest/test/gtest-typed-test_test.cc
View file @
ce654c2f
...
@@ -193,13 +193,13 @@ TYPED_TEST(TypedTestWithNames, TestSuiteName) {
...
@@ -193,13 +193,13 @@ TYPED_TEST(TypedTestWithNames, TestSuiteName) {
if
(
std
::
is_same
<
TypeParam
,
char
>::
value
)
{
if
(
std
::
is_same
<
TypeParam
,
char
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
current_test_info
()
->
test_
cas
e_name
(),
->
test_
suit
e_name
(),
"TypedTestWithNames/char0"
);
"TypedTestWithNames/char0"
);
}
}
if
(
std
::
is_same
<
TypeParam
,
int
>::
value
)
{
if
(
std
::
is_same
<
TypeParam
,
int
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
current_test_info
()
->
test_
cas
e_name
(),
->
test_
suit
e_name
(),
"TypedTestWithNames/int1"
);
"TypedTestWithNames/int1"
);
}
}
}
}
...
@@ -315,13 +315,13 @@ TYPED_TEST_P(TypeParametrizedTestWithNames, TestSuiteName) {
...
@@ -315,13 +315,13 @@ TYPED_TEST_P(TypeParametrizedTestWithNames, TestSuiteName) {
if
(
std
::
is_same
<
TypeParam
,
char
>::
value
)
{
if
(
std
::
is_same
<
TypeParam
,
char
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
current_test_info
()
->
test_
cas
e_name
(),
->
test_
suit
e_name
(),
"CustomName/TypeParametrizedTestWithNames/parChar0"
);
"CustomName/TypeParametrizedTestWithNames/parChar0"
);
}
}
if
(
std
::
is_same
<
TypeParam
,
int
>::
value
)
{
if
(
std
::
is_same
<
TypeParam
,
int
>::
value
)
{
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
EXPECT_STREQ
(
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
()
->
current_test_info
()
->
test_
cas
e_name
(),
->
test_
suit
e_name
(),
"CustomName/TypeParametrizedTestWithNames/parInt1"
);
"CustomName/TypeParametrizedTestWithNames/parInt1"
);
}
}
}
}
...
...
googletest/test/gtest_unittest.cc
View file @
ce654c2f
...
@@ -218,17 +218,18 @@ using testing::GTEST_FLAG(stream_result_to);
...
@@ -218,17 +218,18 @@ using testing::GTEST_FLAG(stream_result_to);
using
testing
::
GTEST_FLAG
(
throw_on_failure
);
using
testing
::
GTEST_FLAG
(
throw_on_failure
);
using
testing
::
IsNotSubstring
;
using
testing
::
IsNotSubstring
;
using
testing
::
IsSubstring
;
using
testing
::
IsSubstring
;
using
testing
::
kMaxStackTraceDepth
;
using
testing
::
Message
;
using
testing
::
Message
;
using
testing
::
ScopedFakeTestPartResultReporter
;
using
testing
::
ScopedFakeTestPartResultReporter
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
Test
;
using
testing
::
Test
;
using
testing
::
TestCase
;
using
testing
::
TestEventListeners
;
using
testing
::
TestEventListeners
;
using
testing
::
TestInfo
;
using
testing
::
TestInfo
;
using
testing
::
TestPartResult
;
using
testing
::
TestPartResult
;
using
testing
::
TestPartResultArray
;
using
testing
::
TestPartResultArray
;
using
testing
::
TestProperty
;
using
testing
::
TestProperty
;
using
testing
::
TestResult
;
using
testing
::
TestResult
;
using
testing
::
TestSuite
;
using
testing
::
TimeInMillis
;
using
testing
::
TimeInMillis
;
using
testing
::
UnitTest
;
using
testing
::
UnitTest
;
using
testing
::
internal
::
AlwaysFalse
;
using
testing
::
internal
::
AlwaysFalse
;
...
@@ -244,7 +245,6 @@ using testing::internal::FloatingPoint;
...
@@ -244,7 +245,6 @@ using testing::internal::FloatingPoint;
using
testing
::
internal
::
ForEach
;
using
testing
::
internal
::
ForEach
;
using
testing
::
internal
::
FormatEpochTimeInMillisAsIso8601
;
using
testing
::
internal
::
FormatEpochTimeInMillisAsIso8601
;
using
testing
::
internal
::
FormatTimeInMillisAsSeconds
;
using
testing
::
internal
::
FormatTimeInMillisAsSeconds
;
using
testing
::
internal
::
GTestFlagSaver
;
using
testing
::
internal
::
GetCurrentOsStackTraceExceptTop
;
using
testing
::
internal
::
GetCurrentOsStackTraceExceptTop
;
using
testing
::
internal
::
GetElementOr
;
using
testing
::
internal
::
GetElementOr
;
using
testing
::
internal
::
GetNextRandomSeed
;
using
testing
::
internal
::
GetNextRandomSeed
;
...
@@ -253,11 +253,14 @@ using testing::internal::GetTestTypeId;
...
@@ -253,11 +253,14 @@ using testing::internal::GetTestTypeId;
using
testing
::
internal
::
GetTimeInMillis
;
using
testing
::
internal
::
GetTimeInMillis
;
using
testing
::
internal
::
GetTypeId
;
using
testing
::
internal
::
GetTypeId
;
using
testing
::
internal
::
GetUnitTestImpl
;
using
testing
::
internal
::
GetUnitTestImpl
;
using
testing
::
internal
::
GTestFlagSaver
;
using
testing
::
internal
::
Int32FromEnvOrDie
;
using
testing
::
internal
::
Int32FromEnvOrDie
;
using
testing
::
internal
::
IsAProtocolMessage
;
using
testing
::
internal
::
IsAProtocolMessage
;
using
testing
::
internal
::
IsContainer
;
using
testing
::
internal
::
IsContainer
;
using
testing
::
internal
::
IsContainerTest
;
using
testing
::
internal
::
IsContainerTest
;
using
testing
::
internal
::
IsNotContainer
;
using
testing
::
internal
::
IsNotContainer
;
using
testing
::
internal
::
kMaxRandomSeed
;
using
testing
::
internal
::
kTestTypeIdInGoogleTest
;
using
testing
::
internal
::
NativeArray
;
using
testing
::
internal
::
NativeArray
;
using
testing
::
internal
::
OsStackTraceGetter
;
using
testing
::
internal
::
OsStackTraceGetter
;
using
testing
::
internal
::
OsStackTraceGetterInterface
;
using
testing
::
internal
::
OsStackTraceGetterInterface
;
...
@@ -279,9 +282,6 @@ using testing::internal::WideStringToUtf8;
...
@@ -279,9 +282,6 @@ using testing::internal::WideStringToUtf8;
using
testing
::
internal
::
edit_distance
::
CalculateOptimalEdits
;
using
testing
::
internal
::
edit_distance
::
CalculateOptimalEdits
;
using
testing
::
internal
::
edit_distance
::
CreateUnifiedDiff
;
using
testing
::
internal
::
edit_distance
::
CreateUnifiedDiff
;
using
testing
::
internal
::
edit_distance
::
EditType
;
using
testing
::
internal
::
edit_distance
::
EditType
;
using
testing
::
internal
::
kMaxRandomSeed
;
using
testing
::
internal
::
kTestTypeIdInGoogleTest
;
using
testing
::
kMaxStackTraceDepth
;
#if GTEST_HAS_STREAM_REDIRECTION
#if GTEST_HAS_STREAM_REDIRECTION
using
testing
::
internal
::
CaptureStdout
;
using
testing
::
internal
::
CaptureStdout
;
...
@@ -5339,7 +5339,7 @@ class TestInfoTest : public Test {
...
@@ -5339,7 +5339,7 @@ class TestInfoTest : public Test {
TEST_F
(
TestInfoTest
,
Names
)
{
TEST_F
(
TestInfoTest
,
Names
)
{
const
TestInfo
*
const
test_info
=
GetTestInfo
(
"Names"
);
const
TestInfo
*
const
test_info
=
GetTestInfo
(
"Names"
);
ASSERT_STREQ
(
"TestInfoTest"
,
test_info
->
test_
cas
e_name
());
ASSERT_STREQ
(
"TestInfoTest"
,
test_info
->
test_
suit
e_name
());
ASSERT_STREQ
(
"Names"
,
test_info
->
name
());
ASSERT_STREQ
(
"Names"
,
test_info
->
name
());
}
}
...
@@ -5409,7 +5409,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, CodeLocationForTYPEDTESTP, int);
...
@@ -5409,7 +5409,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, CodeLocationForTYPEDTESTP, int);
// 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
// Legacy API is deprecated but still available
#ifndef
REMOVE_LEGACY_TEST_CASEAPI
#ifndef
GTEST_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
...
@@ -5468,7 +5468,7 @@ TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); }
...
@@ -5468,7 +5468,7 @@ 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
#endif //
GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Tests SetupTestSuite/TearDown TestSuite
// Tests SetupTestSuite/TearDown TestSuite
class
SetUpTestSuiteTest
:
public
Test
{
class
SetUpTestSuiteTest
:
public
Test
{
...
@@ -6374,8 +6374,8 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestSuite) {
...
@@ -6374,8 +6374,8 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestSuite) {
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_
cas
e_name
())
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_
suit
e_name
())
<<
"Expected the name of the currently running test
cas
e."
;
<<
"Expected the name of the currently running test
suit
e."
;
EXPECT_STREQ
(
"WorksForFirstTestInATestSuite"
,
test_info
->
name
())
EXPECT_STREQ
(
"WorksForFirstTestInATestSuite"
,
test_info
->
name
())
<<
"Expected the name of the currently running test."
;
<<
"Expected the name of the currently running test."
;
}
}
...
@@ -6389,8 +6389,8 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestSuite) {
...
@@ -6389,8 +6389,8 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestSuite) {
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_
cas
e_name
())
EXPECT_STREQ
(
"CurrentTestInfoTest"
,
test_info
->
test_
suit
e_name
())
<<
"Expected the name of the currently running test
cas
e."
;
<<
"Expected the name of the currently running test
suit
e."
;
EXPECT_STREQ
(
"WorksForSecondTestInATestSuite"
,
test_info
->
name
())
EXPECT_STREQ
(
"WorksForSecondTestInATestSuite"
,
test_info
->
name
())
<<
"Expected the name of the currently running test."
;
<<
"Expected the name of the currently running test."
;
}
}
...
...
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