@@ -68,6 +68,8 @@ class GTestAutoRegister {
6868 public:
6969 GTestAutoRegister () {
7070 ScopedVisibility _;
71+ static constexpr auto has_tests = std::is_same<decltype (T{}.test ()), void >::value;
72+ static_assert (not has_tests, " At least one SHOULD/test is required!" );
7173 T{}.test ();
7274 }
7375};
@@ -94,32 +96,37 @@ class GTest {
9496
9597template <class T >
9698class GTest <T, std::false_type> {};
97-
9899} // detail
99100
100101template <class T >
101102class GTest : public detail ::GTest<T>, public Test {};
102-
103103} // v1
104104} // testing
105105
106- #define GTEST (TYPE ) \
107- template <class > \
108- class GTest__ ; \
109- template <> \
110- class GTest__ <TYPE> : public ::testing::detail::GTest<TYPE> { \
111- using TEST_TYPE = GTest__; \
112- static constexpr auto TEST_NAME = #TYPE; \
113- \
114- public: \
115- void test (); \
116- }; \
117- ::testing::detail::GTestAutoRegister<GTest__<TYPE>> __GUNIT_CAT (ar, __LINE__){}; \
118- void GTest__<TYPE>::test()
106+ #if defined(__clang__)
107+ #pragma clang diagnostic ignored "-Wreturn-type"
108+ #elif defined(__GNUC__)
109+ #pragma GCC diagnostic ignored "-Wreturn-type"
110+ #endif
111+
112+ #define GTEST (TYPE ) \
113+ template <class > \
114+ class GTEST ; \
115+ template <> \
116+ class GTEST <TYPE> : public ::testing::detail::GTest<TYPE> { \
117+ using TEST_TYPE = GTEST; \
118+ static constexpr auto TEST_NAME = #TYPE; \
119+ \
120+ public: \
121+ auto test (); \
122+ }; \
123+ ::testing::detail::GTestAutoRegister<GTEST<TYPE>> __GUNIT_CAT (ar, __LINE__){}; \
124+ auto GTEST<TYPE>::test()
119125
120126#define SHOULD (NAME ) \
121127 static auto __GUNIT_CAT (once_, __LINE__) = true; \
122128 const auto __GUNIT_CAT (test_case_name_, __LINE__) = std::string{" should " } + NAME; \
129+ if (false ) return ::testing::detail::string<' S' , ' H' , ' O' , ' U' , ' L' , ' D' >{}; \
123130 if (__GUNIT_CAT(once_, __LINE__)) { \
124131 __GUNIT_CAT (once_, __LINE__) = false ; \
125132 ::testing::internal::MakeAndRegisterTestInfo (TEST_NAME, __GUNIT_CAT(test_case_name_, __LINE__).c_str(), nullptr, nullptr, \
0 commit comments