3 #ifndef INCLUDE_NN_NLIB_TESTING_TESTING_H_ 4 #define INCLUDE_NN_NLIB_TESTING_TESTING_H_ 15 namespace testing = ::nlib_ns::testing;
18 inline void InitGoogleTest(
int* argc,
char** argv) {
InitNintendoTest(argc, argv); }
19 inline void InitGoogleTest(
int* argc,
wchar_t** argv) {
InitNintendoTest(argc, argv); }
20 #define NLIB_TESTING_OSTREAM ::nlib_ns::testing::detail_func::DummyStream 25 #include "gtest/gtest.h" 27 #define NLIB_TESTING_OSTREAM std::ostream 29 inline void InitNintendoTest(
int* argc,
char** argv) { InitGoogleTest(argc, argv); }
30 inline void InitNintendoTest(
int* argc,
wchar_t** argv) { InitGoogleTest(argc, argv); }
35 #if defined(_MSC_VER) && defined(_PREFAST_) 38 struct MsvcAnalyzeHelper_ {
40 MsvcAnalyzeHelper_& operator<<(T x) {
return *
this; }
41 operator int()
const {
return 1; }
44 #define FAIL() throw MsvcAnalyzeHelper_() 49 #define ASSERT_TRUE(e) if (!(e)) throw MsvcAnalyzeHelper_() 51 #define ASSERT_FALSE(e) if (e) throw MsvcAnalyzeHelper_() 53 #define EXPECT_TRUE(e) if (!(e)) throw MsvcAnalyzeHelper_() 55 #define EXPECT_FALSE(e) if (e) throw MsvcAnalyzeHelper_() 58 #define ASSERT_EQ(a, b) if (!((a) == (b))) throw MsvcAnalyzeHelper_() 60 #define EXPECT_EQ(a, b) if (!((a) == (b))) throw MsvcAnalyzeHelper_() 63 #define ASSERT_NE(a, b) if ((a) == (b)) throw MsvcAnalyzeHelper_() 65 #define EXPECT_NE(a, b) if ((a) == (b)) throw MsvcAnalyzeHelper_() 68 #define ASSERT_LE(a, b) if ((a) > (b)) throw MsvcAnalyzeHelper_() 70 #define EXPECT_LE(a, b) if ((a) > (b)) throw MsvcAnalyzeHelper_() 73 #define ASSERT_LT(a, b) if ((a) >= (b)) throw MsvcAnalyzeHelper_() 75 #define EXPECT_LT(a, b) if ((a) >= (b)) throw MsvcAnalyzeHelper_() 78 #define ASSERT_GE(a, b) if ((a) < (b)) throw MsvcAnalyzeHelper_() 80 #define EXPECT_GE(a, b) if ((a) < (b)) throw MsvcAnalyzeHelper_() 83 #define ASSERT_GT(a, b) if ((a) <= (b)) throw MsvcAnalyzeHelper_() 85 #define EXPECT_GT(a, b) if ((a) <= (b)) throw MsvcAnalyzeHelper_() 88 #define ASSERT_STREQ(a, b) if (NLIB_NS::StrCmp((a), (b)) != 0) throw MsvcAnalyzeHelper_() 90 #define EXPECT_STREQ(a, b) if (NLIB_NS::StrCmp((a), (b)) != 0) throw MsvcAnalyzeHelper_() 93 #define ASSERT_STRNE(a, b) if (NLIB_NS::StrCmp((a), (b)) == 0) throw MsvcAnalyzeHelper_() 95 #define EXPECT_STRNE(a, b) if (NLIB_NS::StrCmp((a), (b)) == 0) throw MsvcAnalyzeHelper_() 97 #undef ASSERT_STRCASEEQ 98 #define ASSERT_STRCASEEQ(a, b) if (NLIB_NS::StrCmp((a), (b)) != 0) throw MsvcAnalyzeHelper_() 99 #undef EXPECT_STRCASEEQ 100 #define EXPECT_STRCASEEQ(a, b) if (NLIB_NS::StrCmp((a), (b)) != 0) throw MsvcAnalyzeHelper_() 102 #undef ASSERT_STRCASENE 103 #define ASSERT_STRCASENE(a, b) if (NLIB_NS::StrCmp((a), (b)) == 0) throw MsvcAnalyzeHelper_() 104 #undef EXPECT_STRCASENE 105 #define EXPECT_STRCASENE(a, b) if (NLIB_NS::StrCmp((a), (b)) == 0) throw MsvcAnalyzeHelper_() 107 #undef ASSERT_FLOAT_EQ 108 #define ASSERT_FLOAT_EQ(a, b) if ((a) != (b)) throw MsvcAnalyzeHelper_() 109 #undef EXPECT_FLOAT_EQ 110 #define EXPECT_FLOAT_EQ(a, b) if ((a) != (b)) throw MsvcAnalyzeHelper_() 112 #undef ASSERT_DOUBLE_EQ 113 #define ASSERT_DOUBLE_EQ(a, b) if ((a) != (b)) throw MsvcAnalyzeHelper_() 114 #undef EXPECT_DOUBLE_EQ 115 #define EXPECT_DOUBLE_EQ(a, b) if ((a) != (b)) throw MsvcAnalyzeHelper_() 118 #define ASSERT_NEAR(a, b, c) if (!((a) == (b))) throw MsvcAnalyzeHelper_() 120 #define EXPECT_NEAR(a, b, c) if (!((a) == (b))) throw MsvcAnalyzeHelper_() 125 #endif // INCLUDE_NN_NLIB_TESTING_TESTING_H_ Controls display when tests fails.
Defines a test that parameterizes values.
void InitNintendoTest(int *argc, char **argv)
Processes command-line options for the test program.
A file that contains the configuration information for each development environment.
Defines the macro for a basic, simple test.
Wraps functions like strlen and strcpy so they can be safely used.
Defines a predicate assertion.