diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-05 14:16:57 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-05 14:16:57 +0200 |
commit | f4bb6d57cc88a7e25b3a5f43faafa49a7f500b7c (patch) | |
tree | be9be8157c10599f572d20113795dc14c620a292 | |
parent | 65eda52aa51017f6f7aad158c4f8b6e91054cf0d (diff) |
restructure unit tests and dummies
-rw-r--r-- | readme.md | 3 | ||||
-rw-r--r-- | src/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/crepe/Sound.cpp | 1 | ||||
-rw-r--r-- | src/example/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/example/audio_internal.cpp (renamed from src/dummy_audio.cpp) | 10 | ||||
-rw-r--r-- | src/readme.md | 8 | ||||
-rw-r--r-- | src/test/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/test/audio.cpp (renamed from test/audio.cpp) | 1 | ||||
-rw-r--r-- | src/test/dummy.cpp (renamed from test/dummy.cpp) | 1 | ||||
-rw-r--r-- | test/CMakeLists.txt | 23 |
10 files changed, 37 insertions, 29 deletions
@@ -7,7 +7,8 @@ This repository contains: |`lib/`|third-party libraries as git submodules| |`mwe/`|minimal working examples and proof-of-concepts| |`src/crepe/`|game engine source code| -|`test/`|game engine unit tests| +|`src/test/`|unit tests| +|`src/example`|standalone examples using game engine| ## Compilation diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 232d330..62ca9a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,10 +9,12 @@ set(CMAKE_BUILD_TYPE Debug) add_compile_definitions(DEBUG) add_subdirectory(../lib/soloud soloud) +add_subdirectory(../lib/googletest googletest) project(crepe C CXX) add_library(crepe SHARED) +add_executable(test_main EXCLUDE_FROM_ALL) target_include_directories(crepe PUBLIC SYSTEM INTERFACE . @@ -24,13 +26,16 @@ target_link_libraries(crepe ) add_subdirectory(crepe) +add_subdirectory(test) +add_subdirectory(example) install( TARGETS crepe FILE_SET HEADERS DESTINATION include/crepe ) - -add_executable(dummy_audio dummy_audio.cpp) -target_link_libraries(dummy_audio PUBLIC crepe) +target_link_libraries(test_main + PRIVATE gtest_main + PUBLIC crepe +) diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp index e1150ac..1758282 100644 --- a/src/crepe/Sound.cpp +++ b/src/crepe/Sound.cpp @@ -58,3 +58,4 @@ void Sound::set_looping(bool looping) { if (!ctx.engine.isValidVoiceHandle(this->handle)) return; ctx.engine.setLooping(this->handle, this->looping); } + diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt new file mode 100644 index 0000000..bcc9271 --- /dev/null +++ b/src/example/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(audio_internal EXCLUDE_FROM_ALL audio_internal.cpp) +target_link_libraries(audio_internal PUBLIC crepe) + diff --git a/src/dummy_audio.cpp b/src/example/audio_internal.cpp index 049bb49..09bd55c 100644 --- a/src/dummy_audio.cpp +++ b/src/example/audio_internal.cpp @@ -1,5 +1,10 @@ -#include "crepe/Sound.h" -#include "crepe/util/log.h" +/** \file + * + * Standalone example for usage of the internal \c Sound class. + */ + +#include <crepe/Sound.h> +#include <crepe/util/log.h> #include <chrono> #include <thread> @@ -38,3 +43,4 @@ int main() { return 0; } + diff --git a/src/readme.md b/src/readme.md new file mode 100644 index 0000000..1c5d3a2 --- /dev/null +++ b/src/readme.md @@ -0,0 +1,8 @@ +# engine source + +This folder contains the crêpe engine source files, unit tests, and some toy +examples. The only target built by default by the CMakeLists.txt in this folder +is the crêpe shared library object. Unit tests can be built by explicitly +specifying the target `test_main` when running the build command. Each source +file in the example/ folder corresponds to a CMake target as well. + diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt new file mode 100644 index 0000000..0d316d6 --- /dev/null +++ b/src/test/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(test_main PUBLIC + dummy.cpp + # audio.cpp +) + diff --git a/test/audio.cpp b/src/test/audio.cpp index 47c5e84..5bb2607 100644 --- a/test/audio.cpp +++ b/src/test/audio.cpp @@ -26,3 +26,4 @@ TEST(audio, play) { ASSERT_TRUE(true); } + diff --git a/test/dummy.cpp b/src/test/dummy.cpp index a00a9c6..7f4c083 100644 --- a/test/dummy.cpp +++ b/src/test/dummy.cpp @@ -1,3 +1,4 @@ #include <gtest/gtest.h> TEST(dummy, foo) { ASSERT_TRUE(1); } + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index f015570..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.28) - -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) - -set(CMAKE_BUILD_TYPE Debug) - -project(test C CXX) - -add_subdirectory(../lib/googletest googletest) -add_subdirectory(../src crepe) - -add_executable(test - dummy.cpp - # audio.cpp -) - -target_link_libraries(test - PRIVATE gtest_main - PUBLIC crepe # TODO: this does not work properly -) - |