Make the unittest build using CMake

This commit is contained in:
Henrik Rydgård 2014-01-09 12:09:07 +01:00
parent 51484e48a9
commit 8ac6ba17d7
2 changed files with 19 additions and 5 deletions

View File

@ -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})

View File

@ -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;
}
}