Add tests with CMake
authorNicholas Guriev <guriev-ns@ya.ru>
Sun, 21 Jul 2019 09:35:36 +0000 (12:35 +0300)
committerHermet Park <hermetpark@gmail.com>
Tue, 23 Jul 2019 04:45:47 +0000 (13:45 +0900)
CMakeLists.txt
test/CMakeLists.txt [new file with mode: 0644]

index 409c172..1bb5c35 100644 (file)
@@ -24,6 +24,7 @@ add_library(rlottie::rlottie ALIAS rlottie)
 option(LOTTIE_MODULE "Enable LOTTIE MODULE SUPPORT" ON)
 option(LOTTIE_THREAD "Enable LOTTIE THREAD SUPPORT" ON)
 option(LOTTIE_CACHE "Enable LOTTIE CACHE SUPPORT" ON)
+option(LOTTIE_TEST "Build LOTTIE AUTOTESTS" OFF)
 
 CONFIGURE_FILE(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in config.h)
 
@@ -87,6 +88,11 @@ add_subdirectory(inc)
 add_subdirectory(src)
 add_subdirectory(example)
 
+if (LOTTIE_TEST)
+    enable_testing()
+    add_subdirectory(test)
+endif()
+
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_DIR ${PREFIX})
 SET(LIBDIR ${LIB_INSTALL_DIR})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..235c18b
--- /dev/null
@@ -0,0 +1,21 @@
+project(rlottie_tests CXX)
+find_package(GTest REQUIRED)
+
+add_definitions(-DDEMO_DIR="${CMAKE_SOURCE_DIR}/example/resource/")
+link_libraries(GTest::GTest GTest::Main)
+
+add_executable(vectorTestSuite testsuite.cpp test_vrect.cpp test_vpath.cpp
+    ${CMAKE_SOURCE_DIR}/src/vector/vbezier.cpp
+    ${CMAKE_SOURCE_DIR}/src/vector/vdebug.cpp
+    ${CMAKE_SOURCE_DIR}/src/vector/vmatrix.cpp
+    ${CMAKE_SOURCE_DIR}/src/vector/vpath.cpp
+    ${CMAKE_SOURCE_DIR}/src/vector/pixman/vregion.cpp)
+target_include_directories(vectorTestSuite PRIVATE ${CMAKE_BINARY_DIR}
+    ${CMAKE_SOURCE_DIR}/src/vector ${CMAKE_SOURCE_DIR}/src/vector/pixman)
+gtest_add_tests(vectorTestSuite "" AUTO)
+
+add_executable(animationTestSuite testsuite.cpp
+    test_lottieanimation.cpp test_lottieanimation_capi.cpp)
+target_include_directories(animationTestSuite PRIVATE ${CMAKE_SOURCE_DIR}/inc)
+target_link_libraries(animationTestSuite PRIVATE rlottie)
+gtest_add_tests(animationTestSuite "" AUTO)