Test solver

This commit is contained in:
David Allemang
2022-09-13 14:36:50 -04:00
parent 75725ff499
commit f606ea3b4b
4 changed files with 136 additions and 31 deletions

View File

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

View File

@@ -1,11 +0,0 @@
#include <tc/core.hpp>
#include <tc/groups.hpp>
#include <Eigen/Eigen>
#include <iostream>
int main() {
auto group = tc::group::H(4);
auto cos = group.solve({});
std::cout << cos.size() << std::endl;
}

View File

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

96
tc/test/tctest.cpp Normal file
View File

@@ -0,0 +1,96 @@
#include <iostream>
#include <string>
#include <vector>
#include <tc/groups.hpp>
#include <tc/core.hpp>
int main(int argc, char *argv[]) {
std::string key = argv[1];
std::vector<std::pair<tc::Group, size_t>> 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;
}