Skip to content

Commit 4105eb7

Browse files
Abseil Teamgennadiycivil
Abseil Team
authored andcommitted
Googletest export
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
1 parent 68319c1 commit 4105eb7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

googletest/include/gtest/internal/gtest-internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,10 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }
13481348

13491349
// Helper macro for defining tests.
13501350
#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id) \
1351+
static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1, \
1352+
"test_suite_name must not be empty"); \
1353+
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
1354+
"test_name must not be empty"); \
13511355
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
13521356
: public parent_class { \
13531357
public: \

0 commit comments

Comments
 (0)