5 #ifndef STORAGE_LEVELDB_UTIL_TESTHARNESS_H_
6 #define STORAGE_LEVELDB_UTIL_TESTHARNESS_H_
33 extern std::string
TmpDir();
47 std::stringstream
ss_;
51 : ok_(true), fname_(f), line_(l) {
56 fprintf(stderr,
"%s:%d:%s\n", fname_, line_, ss_.str().c_str());
63 ss_ <<
" Assertion failure " << msg;
77 #define BINARY_OP(name,op) \
78 template <class X, class Y> \
79 Tester& name(const X& x, const Y& y) { \
81 ss_ << " failed: " << x << (" " #op " ") << y; \
105 #define ASSERT_TRUE(c) ::leveldb::test::Tester(__FILE__, __LINE__).Is((c), #c)
106 #define ASSERT_OK(s) ::leveldb::test::Tester(__FILE__, __LINE__).IsOk((s))
107 #define ASSERT_EQ(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsEq((a),(b))
108 #define ASSERT_NE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsNe((a),(b))
109 #define ASSERT_GE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsGe((a),(b))
110 #define ASSERT_GT(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsGt((a),(b))
111 #define ASSERT_LE(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsLe((a),(b))
112 #define ASSERT_LT(a,b) ::leveldb::test::Tester(__FILE__, __LINE__).IsLt((a),(b))
114 #define TCONCAT(a,b) TCONCAT1(a,b)
115 #define TCONCAT1(a,b) a##b
117 #define TEST(base,name) \
118 class TCONCAT(_Test_,name) : public base { \
121 static void _RunIt() { \
122 TCONCAT(_Test_,name) t; \
126 bool TCONCAT(_Test_ignored_,name) = \
127 ::leveldb::test::RegisterTest(#base, #name, &TCONCAT(_Test_,name)::_RunIt); \
128 void TCONCAT(_Test_,name)::_Run()
138 #endif // STORAGE_LEVELDB_UTIL_TESTHARNESS_H_
bool RegisterTest(const char *base, const char *name, void(*func)())
Tester & operator<<(const V &value)
Tester & IsOk(const Status &s)
#define BINARY_OP(name, op)
Tester & Is(bool b, const char *msg)
Tester(const char *f, int l)
std::string ToString() const