cmoon::test::assert_true


Defined in module <cmoon.test>


template<class T>
void assert_true(const T& obj, std::string_view message = "", const std::source_location& location = std::source_location::current());


(1)

Throws an assert_exception if obj is false.

This function is ill-formed if obj is not convertible to bool.

Parameters

obj - The boolean to be tested
message - Extra information to be added to the error message
location - Information about where in the file this assertion was ran

Return value

(none)

Example



import cmoon.test;

bool super_complicated_function();

class example_test : public cmoon::test::test_case
{
    public:
        example_test()
            : cmoon::test::test_case{"example test"} {}

        void operator()() override
        {
            const bool value {super_complicated_function()};

            cmoon::test::assert_true(value);
        }
};