#include #include namespace arc::validate { std::map test_t::tests_; test_t:: test_t(std::string file, int line, std::string name, std::function f) : file_{std::move(file)}, line_{line}, name_{ name.empty() ? throw std::invalid_argument{"invalid name"} : name }, function_{std::move(f)} { if (tests_.contains(name)) { throw std::invalid_argument{"test already registered: " + name}; } tests_.emplace(name, this); } test_t:: ~test_t() noexcept { tests_.erase(name_); } std::string const& test_t:: file() const { return file_; } int test_t:: line() const { return line_; } std::string const& test_t:: name() const { return name_; } std::function const& test_t:: function() const { return function_; } std::vector test_t:: get_tests() { std::vector tests; for (auto const& j : tests_) { tests.emplace_back(j.second); } return tests; } std::vector test_t:: get_tests(std::set const& include, std::set const& exclude) { std::vector tests; auto all_tests = get_tests(); for (auto const& j : all_tests) { if (!include.empty() && !include.contains(j->name())) { continue; } if (exclude.contains(j->name())) { continue; } tests.emplace_back(j); } return tests; } } // namespace arc::validate