#include #include #include #include #include "test_dbuf.hpp" #include "test_dict.hpp" #include "test_utf8.hpp" #include "test_str.hpp" #include "test_ckdint.hpp" extern "C" { #include "guf_assert.h" #include "guf_math.h" } static std::vector> g_tests {}; static void init_tests() { g_tests.push_back(std::make_unique("DbufIntTest")); g_tests.push_back(std::make_unique("DbufCstringTest")); g_tests.push_back(std::make_unique("DictSvToIntTest")); g_tests.push_back(std::make_unique("UTF8Test")); g_tests.push_back(std::make_unique("StrTest")); g_tests.push_back(std::make_unique("CkdIntTest")); } int main() { init_tests(); std::cout << "Running " << g_tests.size() << " tests...\n"; // std::cout << "max cap 1:" << dict_sv_i32_max_capacity() << "\n"; // std::cout << "max cap 2:" << dict_cstr_int_max_capacity() << "\n"; size_t num_passed = 0; for (auto &test : g_tests) { Test *tst = test.get(); GUF_ASSERT_RELEASE(tst); tst->before_run(); tst->run(); tst->after_run(); std::cout << "- " << *tst << "\n"; if (tst->passed) { ++num_passed; } } const bool passed_all = (num_passed == g_tests.size()); GUF_ASSERT_RELEASE(num_passed <= g_tests.size()); if (passed_all) { std::cout << "-> SUCCESS: Passed all (" << num_passed << "/" << g_tests.size() << ") tests.\n"; } else { std::cout << "-> FAILURE: Failed " << (g_tests.size() - num_passed) << "/" << g_tests.size() << " tests.\n"; } return passed_all ? EXIT_SUCCESS : EXIT_FAILURE; }