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
1b71f0b2
"vscode:/vscode.git/clone" did not exist on "83d3b47acf8ab7ca010cacd9bc9f06bcabe69c38"
Commit
1b71f0b2
authored
Apr 13, 2010
by
zhanyong.wan
Browse files
Adds alternative spellings for FAIL, SUCCEED, and TEST.
parent
509b5339
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
include/gtest/gtest.h
include/gtest/gtest.h
+20
-3
test/gtest_unittest.cc
test/gtest_unittest.cc
+13
-0
No files found.
include/gtest/gtest.h
View file @
1b71f0b2
...
@@ -1651,10 +1651,22 @@ const T* TestWithParam<T>::parameter_ = NULL;
...
@@ -1651,10 +1651,22 @@ const T* TestWithParam<T>::parameter_ = NULL;
#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
// Generates a fatal failure with a generic message.
// Generates a fatal failure with a generic message.
#define FAIL() GTEST_FATAL_FAILURE_("Failed")
#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
// Define this macro to 1 to omit the definition of FAIL(), which is a
// generic name and clashes with some other libraries.
#if !GTEST_DONT_DEFINE_FAIL
#define FAIL() GTEST_FAIL()
#endif
// Generates a success with a generic message.
// Generates a success with a generic message.
#define SUCCEED() GTEST_SUCCESS_("Succeeded")
#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
// Define this macro to 1 to omit the definition of SUCCEED(), which
// is a generic name and clashes with some other libraries.
#if !GTEST_DONT_DEFINE_SUCCEED
#define SUCCEED() GTEST_SUCCEED()
#endif
// Macros for testing exceptions.
// Macros for testing exceptions.
//
//
...
@@ -1986,10 +1998,15 @@ bool StaticAssertTypeEq() {
...
@@ -1986,10 +1998,15 @@ bool StaticAssertTypeEq() {
// code. GetTestTypeId() is guaranteed to always return the same
// code. GetTestTypeId() is guaranteed to always return the same
// value, as it always calls GetTypeId<>() from the Google Test
// value, as it always calls GetTypeId<>() from the Google Test
// framework.
// framework.
#define TEST(test_case_name, test_name)\
#define
GTEST_
TEST(test_case_name, test_name)\
GTEST_TEST_(test_case_name, test_name, \
GTEST_TEST_(test_case_name, test_name, \
::testing::Test, ::testing::internal::GetTestTypeId())
::testing::Test, ::testing::internal::GetTestTypeId())
// Define this macro to 1 to omit the definition of TEST(), which
// is a generic name and clashes with some other libraries.
#if !GTEST_DONT_DEFINE_TEST
#define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)
#endif
// Defines a test that uses a test fixture.
// Defines a test that uses a test fixture.
//
//
...
...
test/gtest_unittest.cc
View file @
1b71f0b2
...
@@ -6703,3 +6703,16 @@ TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {
...
@@ -6703,3 +6703,16 @@ TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {
EXPECT_FALSE(is_destroyed);
EXPECT_FALSE(is_destroyed);
delete listener;
delete listener;
}
}
// Sanity tests to ensure that the alternative, verbose spellings of
// some of the macros work. We don't test them thoroughly as that
// would be quite involved. Since their implementations are
// straightforward, and they are rarely used, we'll just rely on the
// users to tell us when they are broken.
GTEST_TEST(AlternativeNameTest, Works) { // GTEST_TEST is the same as TEST.
GTEST_SUCCEED() << "OK"; // GTEST_SUCCEED is the same as SUCCEED.
// GTEST_FAIL is the same as FAIL.
EXPECT_FATAL_FAILURE(GTEST_FAIL() << "An expected failure",
"An expected failure");
}
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