-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
add_subdirectory("HyperSonicDrivers") | ||
add_subdirectory("std") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
17
sdl2-hyper-sonic-drivers/test/std/eChannelGroupFormatterTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |