diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f0f1bb..e4318de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ include(External/json.cmake) include_directories(include) +enable_testing() add_subdirectory(tc) add_custom_target(resources DEPENDS resources_output) @@ -31,14 +32,11 @@ add_executable(vis target_link_libraries(vis glfw glad imgui eigen nlohmann_json) add_dependencies(vis resources) -add_executable(serial src/serialtest.cpp) -target_link_libraries(serial eigen nlohmann_json) +#add_executable(serial src/serialtest.cpp) +#target_link_libraries(serial eigen nlohmann_json) -add_executable(tctest src/tctest.cpp) -target_link_libraries(tctest eigen tc) +#add_executable(combotest src/combotest.cpp) +#target_link_libraries(combotest eigen tc) -add_executable(combotest src/combotest.cpp) -target_link_libraries(combotest eigen tc) - -add_executable(geometrytest src/geometrytest.cpp) -target_link_libraries(geometrytest eigen tc nlohmann_json) +#add_executable(geometrytest src/geometrytest.cpp) +#target_link_libraries(geometrytest eigen tc nlohmann_json) diff --git a/src/tctest.cpp b/src/tctest.cpp deleted file mode 100644 index 50360ac..0000000 --- a/src/tctest.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include - -int main() { - auto group = tc::group::H(4); - auto cos = group.solve({}); - - std::cout << cos.size() << std::endl; -} diff --git a/tc/test/CMakeLists.txt b/tc/test/CMakeLists.txt index e9621bd..53a56e4 100644 --- a/tc/test/CMakeLists.txt +++ b/tc/test/CMakeLists.txt @@ -1,13 +1,35 @@ -add_executable(grouptests grouptest.cpp) -target_link_libraries(grouptests PUBLIC tc) +#add_executable(grouptests grouptest.cpp) +#target_link_libraries(grouptests PUBLIC tc) -add_test(NAME GroupIterateRef COMMAND grouptests iterate_ref) -set_tests_properties(GroupIterateRef PROPERTIES TIMEOUT 30) -add_test(NAME GroupIterateConst COMMAND grouptests iterate_const) -set_tests_properties(GroupIterateConst PROPERTIES TIMEOUT 30) -add_test(NAME GroupIterate COMMAND grouptests iterate) -set_tests_properties(GroupIterate PROPERTIES TIMEOUT 30) -add_test(NAME GroupView COMMAND grouptests view) -set_tests_properties(GroupView PROPERTIES TIMEOUT 30) +add_executable(tctests tctest.cpp) +target_link_libraries(tctests PUBLIC tc) -add_custom_target(alltests DEPENDS grouptests) +#add_test(NAME GroupIterateRef COMMAND grouptests iterate_ref) +#set_tests_properties(GroupIterateRef PROPERTIES TIMEOUT 30) +#add_test(NAME GroupIterateConst COMMAND grouptests iterate_const) +#set_tests_properties(GroupIterateConst PROPERTIES TIMEOUT 30) +#add_test(NAME GroupIterate COMMAND grouptests iterate) +#set_tests_properties(GroupIterate PROPERTIES TIMEOUT 30) +#add_test(NAME GroupView COMMAND grouptests view) +#set_tests_properties(GroupView PROPERTIES TIMEOUT 30) + +add_test(NAME SolveA COMMAND tctests A) +set_tests_properties(SolveA PROPERTIES TIMEOUT 5) +add_test(NAME SolveB COMMAND tctests B) +set_tests_properties(SolveB PROPERTIES TIMEOUT 5) +add_test(NAME SolveD COMMAND tctests D) +set_tests_properties(SolveD PROPERTIES TIMEOUT 5) +add_test(NAME SolveE COMMAND tctests E) +set_tests_properties(SolveE PROPERTIES TIMEOUT 5) +add_test(NAME SolveF COMMAND tctests F) +set_tests_properties(SolveF PROPERTIES TIMEOUT 5) +add_test(NAME SolveG COMMAND tctests G) +set_tests_properties(SolveG PROPERTIES TIMEOUT 5) +add_test(NAME SolveH COMMAND tctests H) +set_tests_properties(SolveH PROPERTIES TIMEOUT 5) +add_test(NAME SolveI COMMAND tctests I) +set_tests_properties(SolveI PROPERTIES TIMEOUT 5) +add_test(NAME SolveT COMMAND tctests T) +set_tests_properties(SolveT PROPERTIES TIMEOUT 5) + +add_custom_target(alltests DEPENDS grouptests tctests) diff --git a/tc/test/tctest.cpp b/tc/test/tctest.cpp new file mode 100644 index 0000000..bb0fed6 --- /dev/null +++ b/tc/test/tctest.cpp @@ -0,0 +1,96 @@ +#include +#include +#include + +#include +#include + +int main(int argc, char *argv[]) { + std::string key = argv[1]; + + std::vector> groups; + + // See the group orders here https://en.wikipedia.org/wiki/Coxeter_group#Properties + if (key == "A") { + groups = { + {tc::group::A(1), 2}, + {tc::group::A(2), 6}, + {tc::group::A(3), 24}, + {tc::group::A(4), 120}, + }; + } + if (key == "B") { + groups = { + {tc::group::B(2), 8}, + {tc::group::B(3), 48}, + {tc::group::B(4), 384}, + {tc::group::B(5), 3840}, + {tc::group::B(6), 46080}, + }; + } + if (key == "D") { + groups = { + {tc::group::D(2), 4}, + {tc::group::D(3), 24}, + {tc::group::D(4), 192}, + {tc::group::D(5), 1920}, + {tc::group::D(6), 23040}, + }; + } + if (key == "E") { + groups = { + {tc::group::E(3), 12}, + {tc::group::E(4), 120}, + {tc::group::E(5), 1920}, + {tc::group::E(6), 51840}, + }; + } + if (key == "F") { + groups = { + {tc::group::F4(), 1152}, + }; + } + if (key == "G") { + groups = { + {tc::group::G2(), 12}, + }; + } + if (key == "H") { + groups = { + {tc::group::H(2), 10}, + {tc::group::H(3), 120}, + {tc::group::H(4), 14400}, + }; + } + if (key == "I") { + groups = { + {tc::group::I2(2), 4}, + {tc::group::I2(3), 6}, + {tc::group::I2(4), 8}, + {tc::group::I2(5), 10}, + }; + } + if (key == "T") { + groups = { + {tc::group::T(3), 36}, + {tc::group::T(4), 64}, + {tc::group::T(400), 640000}, + {tc::group::T(400, 300), 480000}, + }; + } + + int status = EXIT_SUCCESS; + + for (const auto &[group, expected]: groups) { + auto cos = group.solve({}); + auto actual = cos.size(); + std::cout << group.name << " : " << actual; + if (expected != actual) { + std::cout << " (Expected " << expected << ")"; + status = EXIT_FAILURE; + } + std::cout << std::endl; + } + + return status; +}