cmoon::test::assert_in


Defined in module <cmoon.test>


template<class T, std::ranges::input_range R>
void assert_in(const T& member, R&& r, std::string_view message = "", const std::source_location& location = std::source_location::current());


(1)

Throws an assert_exception if the member is not in r.

This function is ill-formed if the expression first == second is ill-formed.

Parameters

member - Object to find in range
r - Range to search for member
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 <vector>;

import cmoon.test;

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

        void operator()() override
        {
            const int value {5};
            std::vector<int> values {1, 2, 3, 4, 5};

            cmoon::test::assert_in(value, values);
        }
};