cmoon::test::assert_sequence_equal


Defined in module <cmoon.test>


template<std::input_iterator InputIterator1, std::input_iterator InputIterator2>
    requires std::indirectly_comparable<InputIterator1, InputIterator2, std::equal_to<>>
void assert_sequence_equal(InputIterator1 begin1, InputIterator1 end1, InputIterator2 begin2, std::string_view message = "", const std::source_location& location = std::source_location::current());


(1)


template<std::ranges::input_range Range1, std::ranges::input_range Range2,
            class Pred = std::ranges::equal_to,
            class Proj1 = std::identity, class Proj2 = std::identity>
    requires std::indirectly_comparable<std::ranges::iterator_t<Range1>, 
                                        std::ranges::iterator_t<Range2>, 
                                        Pred,
                                        Proj1,
                                        Proj2>
void assert_sequence_equal(Range1&& r1, Range2&& r2, std::string_view message = "", Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}, const std::source_location& location = std::source_location::current());


(2)

Throws an assert_exception if the two seqences are not equal.

Parameters

begin1 - Iterator to the beginning of the first sequence
end1 - Iterator to end of the first sequence
begin2 - Iterator to the beginning of the second sequence
r1 - First sequence
r2 - Second sequence
pred - Function called for comparison
proj1 - Function to change an element of r1 before comparing
proj2 - Function to change an element of r2 before comparing
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 std::vector<int> expected {1, 2, 3};
            std::vector<int> values {1, 2, 3};

            cmoon::test::assert_sequence_equal(std::begin(values), std::end(values), std::begin(expected));
            cmoon::test::assert_sequence_equal(values, expected);
        }
};