/** * @file TestableUTest.cpp * @author Gustice * @brief * * @copyright Copyright (c) 2024 */ #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "utils.hpp" #include "doctest/doctest.h" #include namespace SingleActiveTests { class Foo : public SingleActive { public: int test{}; Foo() : SingleActive() {} }; template <> bool Foo::SingleActive::active{}; class Bar : public SingleActive { public: int test{}; Bar() : SingleActive() {} }; template <> bool Bar::SingleActive::active{}; TEST_CASE("Sweet path") { { // first instances Foo dut; } // destruction { // second instances Foo dut; } // destruction { // third instance Foo dut1; Bar dut2; // First instance of second class } // destruction CHECK(true); } TEST_CASE("Too many instances") { { Foo dut1; Foo *pDut2; CHECK_THROWS_WITH(pDut2 = new Foo, "Instance already active"); } CHECK(true); } }