Skip to content

Commit

Permalink
fix eChannelGroupFormatter (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello authored Oct 19, 2023
1 parent 4efc103 commit c9e902c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions sdl2-hyper-sonic-drivers/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory("HyperSonicDrivers")
add_subdirectory("std")
63 changes: 63 additions & 0 deletions sdl2-hyper-sonic-drivers/test/std/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<TARGET_FILE:GTest::gtest_main> $<TARGET_FILE_DIR:${TEST_EXE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:GTest::gtest> $<TARGET_FILE_DIR:${TEST_EXE}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:GTest::gmock> $<TARGET_FILE_DIR:${TEST_EXE}>
)

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"
)

17 changes: 17 additions & 0 deletions sdl2-hyper-sonic-drivers/test/std/eChannelGroupFormatterTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <std/eChannelGroupFormatter.hpp>

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();
}

0 comments on commit c9e902c

Please sign in to comment.