mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-12 17:16:44 +02:00
66 lines
1.9 KiB
Diff
66 lines
1.9 KiB
Diff
From: =?utf-8?q?Timo_R=C3=B6hling?= <timo.roehling@fkie.fraunhofer.de>
|
|
Date: Tue, 31 Mar 2020 17:42:23 +0200
|
|
Subject: Integrate unit tests into CMake build
|
|
|
|
Forwarded: not-needed
|
|
---
|
|
CMakeLists.txt | 4 ++++
|
|
tests/CMakeLists.txt | 9 +++++++++
|
|
tests/tester.cc | 4 ++--
|
|
3 files changed, 15 insertions(+), 2 deletions(-)
|
|
create mode 100644 tests/CMakeLists.txt
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 34778cf..5f630da 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -4,6 +4,7 @@ project(TinyGLTF VERSION ${TINYGLTF_VERSION} LANGUAGES CXX)
|
|
|
|
include(GNUInstallDirs)
|
|
include(CMakePackageConfigHelpers)
|
|
+include(CTest)
|
|
|
|
find_package(nlohmann_json 3 REQUIRED)
|
|
find_path(stb_INCLUDE_DIRS NAMES stb_image.h PATH_SUFFIXES stb)
|
|
@@ -77,3 +78,6 @@ install(FILES
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
|
)
|
|
+
|
|
+add_subdirectory(tests)
|
|
+
|
|
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
|
|
new file mode 100644
|
|
index 0000000..80148fc
|
|
--- /dev/null
|
|
+++ b/tests/CMakeLists.txt
|
|
@@ -0,0 +1,9 @@
|
|
+if(BUILD_TESTING)
|
|
+ add_executable(tester tester.cc)
|
|
+ add_test(NAME tester COMMAND tester WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
+ target_include_directories(tester PRIVATE
|
|
+ ${CMAKE_SOURCE_DIR}
|
|
+ ${stb_INCLUDE_DIRS}
|
|
+ )
|
|
+endif()
|
|
+
|
|
diff --git a/tests/tester.cc b/tests/tester.cc
|
|
index 135f84e..a8578bb 100644
|
|
--- a/tests/tester.cc
|
|
+++ b/tests/tester.cc
|
|
@@ -1,13 +1,13 @@
|
|
#define TINYGLTF_IMPLEMENTATION
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
-#include "tiny_gltf.h"
|
|
+#include <tiny_gltf.h>
|
|
|
|
// Nlohmann json(include ../json.hpp)
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
|
-#include "catch.hpp"
|
|
+#include <catch2/catch.hpp>
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|