diff --git a/CMakeLists.txt b/CMakeLists.txt index f80fb7f..59b9ad6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,4 +59,5 @@ target_link_libraries(all_tests PRIVATE tensor_tests utils_tests vector_tests + hall_set_tests ) \ No newline at end of file diff --git a/LibAlgebraUnitTests/CMakeLists.txt b/LibAlgebraUnitTests/CMakeLists.txt index f2bbfd2..e8355e6 100644 --- a/LibAlgebraUnitTests/CMakeLists.txt +++ b/LibAlgebraUnitTests/CMakeLists.txt @@ -9,6 +9,7 @@ target_link_libraries(reporter PUBLIC UnitTest++) add_subdirectory(algebra) add_subdirectory(lie) add_subdirectory(signature_tests) +add_subdirectory(hall_set) add_subdirectory(tensor) add_subdirectory(utils) add_subdirectory(vector) diff --git a/LibAlgebraUnitTests/hall_set/CMakeLists.txt b/LibAlgebraUnitTests/hall_set/CMakeLists.txt new file mode 100644 index 0000000..a0953d4 --- /dev/null +++ b/LibAlgebraUnitTests/hall_set/CMakeLists.txt @@ -0,0 +1,11 @@ + + +add_library(hall_set_tests OBJECT + test_extension_of_functions.cpp + ) + +target_link_libraries(hall_set_tests PUBLIC UnitTest++ Libalgebra::Libalgebra reporter) + +add_executable(hall_set_tests_exe run_tests.cpp) +target_link_libraries(hall_set_tests_exe PRIVATE hall_set_tests) + diff --git a/LibAlgebraUnitTests/hall_set/run_tests.cpp b/LibAlgebraUnitTests/hall_set/run_tests.cpp new file mode 100644 index 0000000..9fd14bb --- /dev/null +++ b/LibAlgebraUnitTests/hall_set/run_tests.cpp @@ -0,0 +1,14 @@ +// +// Created by sam on 02/02/2021. +// + +#include +#include "../reporter.h" + +int main() +{ + reporter report; + UnitTest::TestRunner runner(report); + + return runner.RunTestsIf(UnitTest::Test::GetTestList(), NULL, UnitTest::True(), 0); +} \ No newline at end of file diff --git a/LibAlgebraUnitTests/hall_set/test_extension_of_functions.cpp b/LibAlgebraUnitTests/hall_set/test_extension_of_functions.cpp new file mode 100644 index 0000000..6796b2f --- /dev/null +++ b/LibAlgebraUnitTests/hall_set/test_extension_of_functions.cpp @@ -0,0 +1,146 @@ +// +// Created by sam on 13/09/2021. +// + +#include + +#include + +using namespace alg; + + +std::string letter_func(LET l) +{ + return std::to_string(l); +} + +std::string binary_op(const std::string &l, const std::string &r) +{ + return "[" + l + "," + r + "]"; +} + + +SUITE(hall_set_function_extensions) { + + + struct fixture + { + + typedef hall_basis<5> hall_set_t; + typedef typename hall_set_t::KEY KEY; + + template + using extended_function = hall_set_t::extended_function; + + hall_set_t hall_set; + + + extended_function + non_cached_key2str; + + extended_function> + lazy_cached_key2str; + + extended_function> + table_cached_key2str; + + extended_function> + lazy_nomax_cached_key2str; + + fixture() : hall_set(), + non_cached_key2str(letter_func, binary_op, hall_set), + lazy_cached_key2str(letter_func, binary_op, hall_set), + table_cached_key2str(letter_func, binary_op, hall_set), + lazy_nomax_cached_key2str(letter_func, binary_op, hall_set) + { + hall_set.growup(5); + } + + + + }; + + + TEST_FIXTURE(fixture, test_letter_to_string) { + LET l = 1; + + CHECK_EQUAL("1", hall_set.key2string(l)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_2) { + KEY k = 6; + CHECK_EQUAL("[1,2]", hall_set.key2string(k)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_3) { + KEY k = 16; + CHECK_EQUAL("[1,[1,2]]", hall_set.key2string(k)); + } + + TEST_FIXTURE(fixture, test_letter_to_string_non_cache) { + LET l = 1; + + CHECK_EQUAL("1", non_cached_key2str(l)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_2_non_cache) { + KEY k = 6; + CHECK_EQUAL("[1,2]", non_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_3_non_cache) { + KEY k = 16; + CHECK_EQUAL("[1,[1,2]]", non_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_letter_to_string_lazy_cache) { + LET l = 1; + + CHECK_EQUAL("1", lazy_cached_key2str(l)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_2_lazy_cache) { + KEY k = 6; + CHECK_EQUAL("[1,2]", lazy_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_3_lazy_cache) { + KEY k = 16; + CHECK_EQUAL("[1,[1,2]]", lazy_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_letter_to_string_table_cache) { + LET l = 1; + + CHECK_EQUAL("1", table_cached_key2str(l)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_2_table_cache) { + KEY k = 6; + CHECK_EQUAL("[1,2]", table_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_3_table_cache) { + KEY k = 16; + CHECK_EQUAL("[1,[1,2]]", table_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_letter_to_string_lazy_nomax_cache) { + LET l = 1; + + CHECK_EQUAL("1", lazy_nomax_cached_key2str(l)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_2_lazy_nomax_cache) { + KEY k = 6; + CHECK_EQUAL("[1,2]", lazy_nomax_cached_key2str(k)); + } + + TEST_FIXTURE(fixture, test_key_to_string_deg_3_lazy_nomax_cache) { + KEY k = 16; + CHECK_EQUAL("[1,[1,2]]", lazy_nomax_cached_key2str(k)); + } + + +} + diff --git a/libalgebra b/libalgebra index c4baf20..28a68eb 160000 --- a/libalgebra +++ b/libalgebra @@ -1 +1 @@ -Subproject commit c4baf205ea49a3a5a3c24dfc14871199fc1aac9b +Subproject commit 28a68eb63840a0ac3e7468c6872b2fa8ac66a7d0