1 // Copyright 2009 The RE2 Authors. All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #ifndef UTIL_TEST_H_ 6 #define UTIL_TEST_H_ 7 8 #include "util/util.h" 9 #include "util/flags.h" 10 #include "util/logging.h" 11 12 #define TEST(x, y) \ 13 void x##y(void); \ 14 TestRegisterer r##x##y(x##y, # x "." # y); \ 15 void x##y(void) 16 17 void RegisterTest(void (*)(void), const char*); 18 19 class TestRegisterer { 20 public: TestRegisterer(void (* fn)(void),const char * s)21 TestRegisterer(void (*fn)(void), const char *s) { 22 RegisterTest(fn, s); 23 } 24 }; 25 26 // fatal assertions 27 #define ASSERT_TRUE CHECK 28 #define ASSERT_FALSE(x) CHECK(!(x)) 29 #define ASSERT_EQ CHECK_EQ 30 #define ASSERT_NE CHECK_NE 31 #define ASSERT_LT CHECK_LT 32 #define ASSERT_LE CHECK_LE 33 #define ASSERT_GT CHECK_GT 34 #define ASSERT_GE CHECK_GE 35 36 // nonfatal assertions 37 // TODO(rsc): Do a better job? 38 #define EXPECT_TRUE CHECK 39 #define EXPECT_FALSE(x) CHECK(!(x)) 40 #define EXPECT_EQ CHECK_EQ 41 #define EXPECT_NE CHECK_NE 42 #define EXPECT_LT CHECK_LT 43 #define EXPECT_LE CHECK_LE 44 #define EXPECT_GT CHECK_GT 45 #define EXPECT_GE CHECK_GE 46 47 namespace testing { 48 class MallocCounter { 49 public: MallocCounter(int x)50 MallocCounter(int x) {} 51 static const int THIS_THREAD_ONLY = 0; HeapGrowth()52 long long HeapGrowth() { return 0; } PeakHeapGrowth()53 long long PeakHeapGrowth() { return 0; } Reset()54 void Reset() {} 55 }; 56 } // namespace testing 57 58 #endif // UTIL_TEST_H_ 59