cmoon::test::fail


Defined in module <cmoon.test>


void fail(std::string_view message = "", const std::source_location& location = std::source_location::current());


(1)

Throws an assert_exception immediately.

Can be used when no assertion check exists for the situation or behavior. Can also be used on test cases not yet implemented.

Parameters

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
        {

            if (!super_complicated_function())
            {
                cmoon::test::fail("This test failed!");
            }
        }
};