]> git-server-git.apps.pok.os.sepia.ceph.com Git - googletest.git/commitdiff
Googletest export
authorAbseil Team <absl-team@google.com>
Wed, 2 Oct 2019 23:19:29 +0000 (19:19 -0400)
committerGennadiy Civil <misterg@google.com>
Thu, 3 Oct 2019 14:52:07 +0000 (10:52 -0400)
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

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

index 82ec6e24f1f4bc71f361dd096acb3138d036115c..94c816a28bdb170aec9568e02be4a448a9b4dc7f 100644 (file)
@@ -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:                                                                    \