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/logging.h"
10 
11 namespace testing {
12 std::string TempDir();
13 }  // namespace testing
14 
15 #define TEST(x, y) \
16 	void x##y(void); \
17 	TestRegisterer r##x##y(x##y, # x "." # y); \
18 	void x##y(void)
19 
20 void RegisterTest(void (*)(void), const char*);
21 
22 class TestRegisterer {
23  public:
TestRegisterer(void (* fn)(void),const char * s)24   TestRegisterer(void (*fn)(void), const char *s) {
25     RegisterTest(fn, s);
26   }
27 };
28 
29 // fatal assertions
30 #define ASSERT_TRUE CHECK
31 #define ASSERT_FALSE(x) CHECK(!(x))
32 #define ASSERT_EQ CHECK_EQ
33 #define ASSERT_NE CHECK_NE
34 #define ASSERT_LT CHECK_LT
35 #define ASSERT_LE CHECK_LE
36 #define ASSERT_GT CHECK_GT
37 #define ASSERT_GE CHECK_GE
38 
39 // nonfatal assertions
40 // TODO(rsc): Do a better job?
41 #define EXPECT_TRUE CHECK
42 #define EXPECT_FALSE(x) CHECK(!(x))
43 #define EXPECT_EQ CHECK_EQ
44 #define EXPECT_NE CHECK_NE
45 #define EXPECT_LT CHECK_LT
46 #define EXPECT_LE CHECK_LE
47 #define EXPECT_GT CHECK_GT
48 #define EXPECT_GE CHECK_GE
49 
50 #endif  // UTIL_TEST_H_
51