/* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Andrew Kaster * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include // intentionally first -- we redefine VERIFY and friends in here #include #include #include #include #include namespace Test { class TestSuite { public: static TestSuite& the() { if (s_global == nullptr) s_global = new TestSuite(); return *s_global; } static void release() { if (s_global) delete s_global; s_global = nullptr; } int run(const NonnullRefPtrVector&); int main(const String& suite_name, int argc, char** argv); NonnullRefPtrVector find_cases(const String& search, bool find_tests, bool find_benchmarks); void add_case(const NonnullRefPtr& test_case) { m_cases.append(test_case); } void current_test_case_did_fail() { m_current_test_case_passed = false; } void set_suite_setup(Function setup) { m_setup = move(setup); } private: static TestSuite* s_global; NonnullRefPtrVector m_cases; u64 m_testtime = 0; u64 m_benchtime = 0; String m_suite_name; bool m_current_test_case_passed = true; Function m_setup; }; }