diff --git a/sdl2-hyper-sonic-drivers/src/std/eChannelGroupFormatter.hpp b/sdl2-hyper-sonic-drivers/src/std/eChannelGroupFormatter.hpp index df27c82b..644566f5 100644 --- a/sdl2-hyper-sonic-drivers/src/std/eChannelGroupFormatter.hpp +++ b/sdl2-hyper-sonic-drivers/src/std/eChannelGroupFormatter.hpp @@ -16,7 +16,7 @@ namespace std switch (ch_group) { - using enum HyperSonicDrivers::audio::mixers::eChannelGroup; + using enum HyperSonicDrivers::audio::mixer::eChannelGroup; case Plain: str = "Plain"; diff --git a/sdl2-hyper-sonic-drivers/test/CMakeLists.txt b/sdl2-hyper-sonic-drivers/test/CMakeLists.txt index 8d438763..f6c23d5c 100644 --- a/sdl2-hyper-sonic-drivers/test/CMakeLists.txt +++ b/sdl2-hyper-sonic-drivers/test/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory("HyperSonicDrivers") +add_subdirectory("std") diff --git a/sdl2-hyper-sonic-drivers/test/std/CMakeLists.txt b/sdl2-hyper-sonic-drivers/test/std/CMakeLists.txt new file mode 100644 index 00000000..799ae0bc --- /dev/null +++ b/sdl2-hyper-sonic-drivers/test/std/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required (VERSION 3.21) + +find_package(GTest 1.11 CONFIG REQUIRED) +include(GoogleTest) +include(CMakeParseArguments) + +macro(macro_test) # ${ARGN} link libraries + + set(prefix TEST) + #set(flags DEFAULT) + set(singleValues EXE) + set(multiValues FILES FIXTURES LINKS_PRIVATE) + + cmake_parse_arguments(${prefix} "${flags}" "${singleValues}" "${multiValues}" ${ARGN}) + #message("EXE: ${TEST_EXE}") + #message("FILES: ${TEST_FILES}") + #message("FIXTURES: ${TEST_FIXTURES}") + #message("LINKS_PRIVATE: ${TEST_LINKS_PRIVATE}") + add_executable (${TEST_EXE} ${TEST_FILES}) + target_include_directories(${TEST_EXE} PUBLIC + ${CMAKE_SOURCE_DIR}/sdl2-hyper-sonic-drivers/src + ${CMAKE_SOURCE_DIR}/sdl2-hyper-sonic-drivers/test + ) + #target_link_libraries(${TEST_EXE} PRIVATE ${TEST_LINKS}) + target_link_libraries(${TEST_EXE} PRIVATE GTest::gtest GTest::gmock) + add_custom_command(TARGET ${TEST_EXE} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + ) + + set(fixtures ${TEST_FIXTURES}) + list(LENGTH fixtures num_fixtures) + unset(fixtures) + if(num_fixtures EQUAL 0) + message("${TEST_EXE}: No fixtures declared") + else() + message("${TEST_EXE} Fixtures: ${TEST_FIXTURES}") + foreach(fixture_i ${TEST_FIXTURES}) + message("copy fixture ${fixture_i}") + add_custom_command(TARGET ${TEST_EXE} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/${fixture_i} + ${CMAKE_CURRENT_BINARY_DIR}/${fixture_i} + ) + endforeach() + endif() + + target_link_libraries(${TEST_EXE} PRIVATE ${TEST_LINKS_PRIVATE}) + + #add_test( + # NAME ${TEST_EXE} + # COMMAND ${TEST_EXE} --gtest_output=xml:report.xml + #) + + gtest_discover_tests(${TEST_EXE} PROPERTIES TEST_DISCOVERY_TIMEOUT 600 DISCOVERY_TIMEOUT 600) +endmacro() + +macro_test( + EXE TestEChannelGrouFormatter + FILES "eChannelGroupFormatterTest.cpp" +) + diff --git a/sdl2-hyper-sonic-drivers/test/std/eChannelGroupFormatterTest.cpp b/sdl2-hyper-sonic-drivers/test/std/eChannelGroupFormatterTest.cpp new file mode 100644 index 00000000..43977062 --- /dev/null +++ b/sdl2-hyper-sonic-drivers/test/std/eChannelGroupFormatterTest.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +namespace std +{ + TEST(eChannelGroupFormatter, Music) + { + ASSERT_STRCASEEQ(std::format("{}", HyperSonicDrivers::audio::mixer::eChannelGroup::Music).c_str(), "Music"); + } +} + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}