Skip to content

Commit

Permalink
Googletest export
Browse files Browse the repository at this point in the history
Add a compile time check to ensure that the parameters to TEST and TEST_F are not empty

Some compilers may already fail in that case and even where it works, it's likely to result in technically invalid code by virtue of creating reserved identifiers:
https://en.cppreference.com/w/cpp/language/identifiers

PiperOrigin-RevId: 272543242
  • Loading branch information
Abseil Team authored and gennadiycivil committed Oct 3, 2019
1 parent 68319c1 commit 4105eb7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,10 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }

// Helper macro for defining tests.
#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
"test_suite_name must not be empty"); \
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
"test_name must not be empty"); \
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
: public parent_class { \
public: \
Expand Down

0 comments on commit 4105eb7

Please sign in to comment.