diff --git a/CMakeLists.txt b/CMakeLists.txt index 50ca211dc..3afe73eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,10 @@ if(NOT DEFINED HEADLESS) set(HEADLESS OFF) endif() +if(NOT DEFINED UNITTEST) + set(UNITTEST ON) +endif() + # User-editable options (go into CMakeCache.txt) option(ARM "Set to ON if targeting an ARM processor" ${ARM}) option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS}) @@ -70,6 +74,7 @@ option(IOS "Set to ON if targeting an iOS device" ${IOS}) option(USING_GLES2 "Set to ON if target device uses OpenGL ES 2.0" ${USING_GLES2}) option(USING_QT_UI "Set to ON if you wish to use the Qt frontend wrapper" ${USING_QT_UI}) option(HEADLESS "Set to OFF to not generate the PPSSPPHeadless target" ${HEADLESS}) +option(UNITTEST "Set to OFF to not generate the unittest target" ${UNITTEST}) option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR}) option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG}) @@ -1363,6 +1368,15 @@ if(HEADLESS) setup_target_project(PPSSPPHeadless headless) endif() +if(UNITTEST) + add_executable(unitTest + unittest/UnitTest.cpp + ) + target_link_libraries(unitTest + ${COCOA_LIBRARY} ${LinkCommon}) + setup_target_project(unitTest unittest) +endif() + if (TargetBin) if (IOS) add_executable(${TargetBin} MACOSX_BUNDLE ${NativeAppSource}) diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 54de299eb..252b7ecc4 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -36,10 +36,10 @@ #include "math/math_util.h" #include "util/text/parsers.h" -#define EXPECT_TRUE(a) if (!(a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; } -#define EXPECT_FALSE(a) if ((a)) { printf(__FUNCTION__ ":%i: Test Fail\n", __LINE__); return false; } -#define EXPECT_EQ_FLOAT(a, b) if ((a) != (b)) { printf(__FUNCTION__ ":" __LINE__ ": Test Fail\n%f\nvs\n%f\n", a, b); return false; } -#define EXPECT_EQ_STR(a, b) if (a != b) { printf(__FUNCTION__ ": Test Fail\n%s\nvs\n%s\n", a.c_str(), b.c_str()); return false; } +#define EXPECT_TRUE(a) if (!(a)) { printf("%s:%i: Test Fail\n", __FUNCTION__, __LINE__); return false; } +#define EXPECT_FALSE(a) if ((a)) { printf("%s:%i: Test Fail\n", __FUNCTION__, __LINE__); return false; } +#define EXPECT_EQ_FLOAT(a, b) if ((a) != (b)) { printf("%s:" __LINE__ ": Test Fail\n%f\nvs\n%f\n", __FUNCTION__, a, b); return false; } +#define EXPECT_EQ_STR(a, b) if (a != b) { printf("%s: Test Fail\n%s\nvs\n%s\n", __FUNCTION__, a.c_str(), b.c_str()); return false; } #define RET(a) if (!(a)) { return false; } @@ -320,4 +320,4 @@ int main(int argc, const char *argv[]) TestMathUtil(); TestParsers(); return 0; -} \ No newline at end of file +}