diff --git a/docs/matchers.md b/docs/matchers.md index 8940b6ad..c702fec0 100644 --- a/docs/matchers.md +++ b/docs/matchers.md @@ -231,6 +231,10 @@ definitions to handle generic range-like types. These are: * `AllTrue()` * `NoneTrue()` * `AnyTrue()` +* `RangeEquals(TargetRangeLike&&, Comparator = std::equal_to<>{})` +* `UnorderedRangeEquals(TargetRangeLike&&, Comparator = std::equal_to<>{})` + +> `RangeEquals` and `UnorderedRangeEquals` matchers were [introduced](https://github.com/catchorg/Catch2/pull/2377) in Catch2 X.Y.Z `IsEmpty` should be self-explanatory. It successfully matches objects that are empty according to either `std::empty`, or ADL-found `empty` @@ -257,6 +261,25 @@ all, none, or any of the contained elements are `true`, respectively. It works for ranges of `bool`s and ranges of elements (explicitly) convertible to `bool`. +`RangeEquals` compares the range that the matcher is constructed with +(the "target range") against the range to be tested, element-wise. The +match succeeds if all elements from the two ranges compare equal (using +`operator==` by default). The ranges do not need to be the same type, +and the element types do not need to be the same, as long as they are +comparable. (e.g. you may compare `std::vector` to `std::array`). + +`UnorderedRangeEquals` is similar to `RangeEquals`, but the order +does not matter. For example "1, 2, 3" would match "3, 2, 1", but not +"1, 1, 2, 3" As with `RangeEquals`, `UnorderedRangeEquals` compares +the individual elements using using `operator==` by default. + +Both `RangeEquals` and `UnorderedRangeEquals` optionally accept a +predicate which can be used to compare the containers element-wise. + +To check a container elementwise against a given matcher, use +`AllMatch`. + + ## Writing custom matchers (old style) The old style of writing matchers has been introduced back in Catch diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2791fa30..1e1e31b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -252,6 +252,7 @@ set(MATCHER_HEADERS ${SOURCES_DIR}/matchers/catch_matchers_all.hpp ${SOURCES_DIR}/matchers/catch_matchers_container_properties.hpp ${SOURCES_DIR}/matchers/catch_matchers_contains.hpp + ${SOURCES_DIR}/matchers/catch_matchers_range_equals.hpp ${SOURCES_DIR}/matchers/catch_matchers_exception.hpp ${SOURCES_DIR}/matchers/catch_matchers_floating_point.hpp ${SOURCES_DIR}/matchers/catch_matchers_predicate.hpp diff --git a/src/catch2/matchers/catch_matchers_all.hpp b/src/catch2/matchers/catch_matchers_all.hpp index eadf7082..83fe5386 100644 --- a/src/catch2/matchers/catch_matchers_all.hpp +++ b/src/catch2/matchers/catch_matchers_all.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/matchers/catch_matchers_range_equals.hpp b/src/catch2/matchers/catch_matchers_range_equals.hpp new file mode 100644 index 00000000..bc94e696 --- /dev/null +++ b/src/catch2/matchers/catch_matchers_range_equals.hpp @@ -0,0 +1,136 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED +#define CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED + +#include +#include +#include + +namespace Catch { + namespace Matchers { + + /** + * Matcher for checking that an element contains the same + * elements in the same order + */ + template + class RangeEqualsMatcher final : public MatcherGenericBase { + TargetRangeLike m_desired; + Equality m_predicate; + + public: + template + RangeEqualsMatcher( TargetRangeLike2&& range, + Equality2&& predicate ): + m_desired( CATCH_FORWARD( range ) ), + m_predicate( CATCH_FORWARD( predicate ) ) {} + + template + bool match( RangeLike&& rng ) const { + using std::begin; + using std::end; + return std::equal( begin(m_desired), + end(m_desired), + begin(rng), + end(rng), + m_predicate ); + } + + std::string describe() const override { + return "elements are " + Catch::Detail::stringify( m_desired ); + } + }; + + /** + * Matcher for checking that an element contains the same + * elements (but not necessarily in the same order) + */ + template + class UnorderedRangeEqualsMatcher final : public MatcherGenericBase { + TargetRangeLike m_desired; + Equality m_predicate; + + public: + template + UnorderedRangeEqualsMatcher( TargetRangeLike2&& range, + Equality2&& predicate ): + m_desired( CATCH_FORWARD( range ) ), + m_predicate( CATCH_FORWARD( predicate ) ) {} + + template + bool match( RangeLike&& rng ) const { + using std::begin; + using std::end; + return std::is_permutation( begin( m_desired ), + end( m_desired ), + begin( rng ), + end( rng ), + m_predicate ); + } + + std::string describe() const override { + return "unordered elements are " + + ::Catch::Detail::stringify( m_desired ); + } + }; + + /** + * Creates a matcher that checks if all elements in a range are equal + * to all elements in another range. + * + * Uses `std::equal_to` to do the comparison + */ + template + std::enable_if_t::value, + RangeEqualsMatcher>> + RangeEquals( RangeLike&& range ) { + return { CATCH_FORWARD( range ), std::equal_to<>{} }; + } + + /** + * Creates a matcher that checks if all elements in a range are equal + * to all elements in another range. + * + * Uses to provided predicate `predicate` to do the comparisons + */ + template + RangeEqualsMatcher + RangeEquals( RangeLike&& range, Equality&& predicate ) { + return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; + } + + /** + * Creates a matcher that checks if all elements in a range are equal + * to all elements in another range, in some permutation + * + * Uses `std::equal_to` to do the comparison + */ + template + std::enable_if_t< + !Detail::is_matcher::value, + UnorderedRangeEqualsMatcher>> + UnorderedRangeEquals( RangeLike&& range ) { + return { CATCH_FORWARD( range ), std::equal_to<>{} }; + } + + /** + * Creates a matcher that checks if all elements in a range are equal + * to all elements in another range, in some permuation. + * + * Uses to provided predicate `predicate` to do the comparisons + */ + template + UnorderedRangeEqualsMatcher + UnorderedRangeEquals( RangeLike&& range, Equality&& predicate ) { + return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; + } + } // namespace Matchers +} // namespace Catch + +#endif // CATCH_MATCHERS_RANGE_EQUALS_HPP_INCLUDED diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 64e92396..1262ba98 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -269,6 +269,7 @@ Message from section two :test-result: FAIL Thrown string literals are translated :test-result: PASS Tracker :test-result: PASS Trim strings +:test-result: PASS Type conversions of RangeEquals and similar :test-result: FAIL Unexpected exceptions can be translated :test-result: PASS Upcasting special member functions :test-result: PASS Usage of AllMatch range matcher @@ -277,6 +278,8 @@ Message from section two :test-result: PASS Usage of AnyTrue range matcher :test-result: PASS Usage of NoneMatch range matcher :test-result: PASS Usage of NoneTrue range matcher +:test-result: PASS Usage of RangeEquals range matcher +:test-result: PASS Usage of UnorderedRangeEquals range matcher :test-result: PASS Usage of the SizeIs range matcher :test-result: PASS Use a custom approx :test-result: PASS Variadic macros diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index d6f5ebe9..e8c6a77b 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -262,6 +262,7 @@ :test-result: FAIL Thrown string literals are translated :test-result: PASS Tracker :test-result: PASS Trim strings +:test-result: PASS Type conversions of RangeEquals and similar :test-result: FAIL Unexpected exceptions can be translated :test-result: PASS Upcasting special member functions :test-result: PASS Usage of AllMatch range matcher @@ -270,6 +271,8 @@ :test-result: PASS Usage of AnyTrue range matcher :test-result: PASS Usage of NoneMatch range matcher :test-result: PASS Usage of NoneTrue range matcher +:test-result: PASS Usage of RangeEquals range matcher +:test-result: PASS Usage of UnorderedRangeEquals range matcher :test-result: PASS Usage of the SizeIs range matcher :test-result: PASS Use a custom approx :test-result: PASS Variadic macros diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 1d8ea9a8..4ef3912e 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1859,6 +1859,23 @@ There is no extra whitespace here StringManip.tests.cpp:: passed: trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: array_int_3, !UnorderedRangeEquals( array_int_4 ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: with 1 message: 'ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( list_char_a )' +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( list_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( list_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, !RangeEquals( vector_char_b ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: vector_int_a, !UnorderedRangeEquals( vector_char_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: a, !RangeEquals( b ) for: { 1, 2, 3 } not elements are { 3, 2, 1 } +MatchersRanges.tests.cpp:: passed: a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } +MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } Exception.tests.cpp:: failed: unexpected exception with message: '3.14' UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 @@ -1964,6 +1981,25 @@ MatchersRanges.tests.cpp:: passed: mocked.m_derefed[1] for: true MatchersRanges.tests.cpp:: passed: mocked.m_derefed[2] for: true MatchersRanges.tests.cpp:: passed: !(mocked.m_derefed[3]) for: !false MatchersRanges.tests.cpp:: passed: !(mocked.m_derefed[4]) for: !false +MatchersRanges.tests.cpp:: passed: empty_vector, RangeEquals( empty_vector ) for: { } elements are { } +MatchersRanges.tests.cpp:: passed: empty_vector, !RangeEquals( non_empty_vector ) for: { } not elements are { 1 } +MatchersRanges.tests.cpp:: passed: non_empty_vector, !RangeEquals( empty_vector ) for: { 1 } not elements are { } +MatchersRanges.tests.cpp:: passed: non_empty_array, RangeEquals( non_empty_array ) for: { 1 } elements are { 1 } +MatchersRanges.tests.cpp:: passed: array_a, RangeEquals( array_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !RangeEquals( array_b ) for: { 1, 2, 3 } not elements are { 2, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !RangeEquals( array_c ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: vector_a, !RangeEquals( vector_b ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( vector_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, !RangeEquals( vector_b, close_enough ) for: { 1, 2, 3 } not elements are { 3, 3, 4 } +MatchersRanges.tests.cpp:: passed: empty_vector, UnorderedRangeEquals( empty_vector ) for: { } unordered elements are { } +MatchersRanges.tests.cpp:: passed: empty_vector, !UnorderedRangeEquals( non_empty_vector ) for: { } not unordered elements are { 1 } +MatchersRanges.tests.cpp:: passed: non_empty_vector, !UnorderedRangeEquals( empty_vector ) for: { 1 } not unordered elements are { } +MatchersRanges.tests.cpp:: passed: non_empty_array, UnorderedRangeEquals( non_empty_array ) for: { 1 } unordered elements are { 1 } +MatchersRanges.tests.cpp:: passed: array_a, UnorderedRangeEquals( array_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !UnorderedRangeEquals( array_b ) for: { 1, 2, 3 } not unordered elements are { 2, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_a, !UnorderedRangeEquals( vector_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) for: { 1, 10, 20 } unordered elements are { 11, 21, 2 } +MatchersRanges.tests.cpp:: passed: vector_a, !UnorderedRangeEquals( vector_b, close_enough ) for: { 1, 10, 21 } not unordered elements are { 11, 21, 3 } MatchersRanges.tests.cpp:: passed: empty_vec, SizeIs(0) for: { } has size == 0 MatchersRanges.tests.cpp:: passed: empty_vec, !SizeIs(2) for: { } not has size == 2 MatchersRanges.tests.cpp:: passed: empty_vec, SizeIs(Lt(2)) for: { } size matches is less than 2 @@ -2485,7 +2521,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 404 | 305 passed | 84 failed | 5 skipped | 10 failed as expected -assertions: 2173 | 1997 passed | 145 failed | 31 failed as expected +test cases: 407 | 308 passed | 84 failed | 5 skipped | 10 failed as expected +assertions: 2209 | 2033 passed | 145 failed | 31 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 1b450553..b74d1e04 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -1852,6 +1852,23 @@ There is no extra whitespace here StringManip.tests.cpp:: passed: trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: array_int_3, !UnorderedRangeEquals( array_int_4 ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: with 1 message: 'ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( list_char_a )' +MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( list_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( list_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_int_a, !RangeEquals( vector_char_b ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: vector_int_a, !UnorderedRangeEquals( vector_char_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: a, !RangeEquals( b ) for: { 1, 2, 3 } not elements are { 3, 2, 1 } +MatchersRanges.tests.cpp:: passed: a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } +MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } Exception.tests.cpp:: failed: unexpected exception with message: '3.14' UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 @@ -1957,6 +1974,25 @@ MatchersRanges.tests.cpp:: passed: mocked.m_derefed[1] for: true MatchersRanges.tests.cpp:: passed: mocked.m_derefed[2] for: true MatchersRanges.tests.cpp:: passed: !(mocked.m_derefed[3]) for: !false MatchersRanges.tests.cpp:: passed: !(mocked.m_derefed[4]) for: !false +MatchersRanges.tests.cpp:: passed: empty_vector, RangeEquals( empty_vector ) for: { } elements are { } +MatchersRanges.tests.cpp:: passed: empty_vector, !RangeEquals( non_empty_vector ) for: { } not elements are { 1 } +MatchersRanges.tests.cpp:: passed: non_empty_vector, !RangeEquals( empty_vector ) for: { 1 } not elements are { } +MatchersRanges.tests.cpp:: passed: non_empty_array, RangeEquals( non_empty_array ) for: { 1 } elements are { 1 } +MatchersRanges.tests.cpp:: passed: array_a, RangeEquals( array_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !RangeEquals( array_b ) for: { 1, 2, 3 } not elements are { 2, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !RangeEquals( array_c ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +MatchersRanges.tests.cpp:: passed: vector_a, !RangeEquals( vector_b ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( vector_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, !RangeEquals( vector_b, close_enough ) for: { 1, 2, 3 } not elements are { 3, 3, 4 } +MatchersRanges.tests.cpp:: passed: empty_vector, UnorderedRangeEquals( empty_vector ) for: { } unordered elements are { } +MatchersRanges.tests.cpp:: passed: empty_vector, !UnorderedRangeEquals( non_empty_vector ) for: { } not unordered elements are { 1 } +MatchersRanges.tests.cpp:: passed: non_empty_vector, !UnorderedRangeEquals( empty_vector ) for: { 1 } not unordered elements are { } +MatchersRanges.tests.cpp:: passed: non_empty_array, UnorderedRangeEquals( non_empty_array ) for: { 1 } unordered elements are { 1 } +MatchersRanges.tests.cpp:: passed: array_a, UnorderedRangeEquals( array_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +MatchersRanges.tests.cpp:: passed: array_a, !UnorderedRangeEquals( array_b ) for: { 1, 2, 3 } not unordered elements are { 2, 2, 3 } +MatchersRanges.tests.cpp:: passed: vector_a, !UnorderedRangeEquals( vector_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) for: { 1, 10, 20 } unordered elements are { 11, 21, 2 } +MatchersRanges.tests.cpp:: passed: vector_a, !UnorderedRangeEquals( vector_b, close_enough ) for: { 1, 10, 21 } not unordered elements are { 11, 21, 3 } MatchersRanges.tests.cpp:: passed: empty_vec, SizeIs(0) for: { } has size == 0 MatchersRanges.tests.cpp:: passed: empty_vec, !SizeIs(2) for: { } not has size == 2 MatchersRanges.tests.cpp:: passed: empty_vec, SizeIs(Lt(2)) for: { } size matches is less than 2 @@ -2474,7 +2510,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 404 | 305 passed | 84 failed | 5 skipped | 10 failed as expected -assertions: 2173 | 1997 passed | 145 failed | 31 failed as expected +test cases: 407 | 308 passed | 84 failed | 5 skipped | 10 failed as expected +assertions: 2209 | 2033 passed | 145 failed | 31 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index dd3199f0..fdbe43e2 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1523,6 +1523,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 404 | 319 passed | 69 failed | 6 skipped | 10 failed as expected -assertions: 2156 | 1997 passed | 128 failed | 31 failed as expected +test cases: 407 | 322 passed | 69 failed | 6 skipped | 10 failed as expected +assertions: 2192 | 2033 passed | 128 failed | 31 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 48609d97..826a78ad 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -13098,6 +13098,154 @@ with expansion: == There is no extra whitespace here +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( c_array ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( c_array ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types (differ in array N) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_3, !RangeEquals( array_int_4 ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_3, !UnorderedRangeEquals( array_int_4 ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types and value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers, one random access, one not +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: +with message: + ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( + list_char_a ) + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( list_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( list_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Value type + Two equal containers of different value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, RangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, UnorderedRangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Value type + Two non-equal containers of different value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, !RangeEquals( vector_char_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 2 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, !UnorderedRangeEquals( vector_char_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 2 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Ranges with begin that needs ADL +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + REQUIRE_THAT( a, !RangeEquals( b ) ) +with expansion: + { 1, 2, 3 } not elements are { 3, 2, 1 } + +MatchersRanges.tests.cpp:: PASSED: + REQUIRE_THAT( a, UnorderedRangeEquals( b ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 3, 2, 1 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, RangeEquals( array_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } elements are { 2, 3, 4 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 2, 3, 4 } + ------------------------------------------------------------------------------- Unexpected exceptions can be translated ------------------------------------------------------------------------------- @@ -13957,6 +14105,229 @@ MatchersRanges.tests.cpp:: PASSED: with expansion: !false +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Empty container matches empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, RangeEquals( empty_vector ) ) +with expansion: + { } elements are { } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Empty container does not match non-empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, !RangeEquals( non_empty_vector ) ) +with expansion: + { } not elements are { 1 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_vector, !RangeEquals( empty_vector ) ) +with expansion: + { 1 } not elements are { } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal 1-length non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_array, RangeEquals( non_empty_array ) ) +with expansion: + { 1 } elements are { 1 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal-sized, equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, RangeEquals( array_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal-sized, non-equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !RangeEquals( array_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 2, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !RangeEquals( array_c ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 2 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two non-equal-sized, non-empty containers (with same first elements) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !RangeEquals( vector_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, RangeEquals( vector_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } elements are { 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Custom predicate + Two non-equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !RangeEquals( vector_b, close_enough ) ) +with expansion: + { 1, 2, 3 } not elements are { 3, 3, 4 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Empty container matches empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, UnorderedRangeEquals( empty_vector ) ) +with expansion: + { } unordered elements are { } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Empty container does not match non-empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, !UnorderedRangeEquals( non_empty_vector ) ) +with expansion: + { } not unordered elements are { 1 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_vector, !UnorderedRangeEquals( empty_vector ) ) +with expansion: + { 1 } not unordered elements are { } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal 1-length non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_array, UnorderedRangeEquals( non_empty_array ) ) +with expansion: + { 1 } unordered elements are { 1 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal-sized, equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, UnorderedRangeEquals( array_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal-sized, non-equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !UnorderedRangeEquals( array_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 2, 2, 3 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two non-equal-sized, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !UnorderedRangeEquals( vector_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) ) +with expansion: + { 1, 10, 20 } unordered elements are { 11, 21, 2 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Custom predicate + Two non-equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !UnorderedRangeEquals( vector_b, close_enough ) ) +with expansion: + { 1, 10, 21 } not unordered elements are { 11, 21, 3 } + ------------------------------------------------------------------------------- Usage of the SizeIs range matcher Some with stdlib containers @@ -17722,6 +18093,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 404 | 305 passed | 84 failed | 5 skipped | 10 failed as expected -assertions: 2173 | 1997 passed | 145 failed | 31 failed as expected +test cases: 407 | 308 passed | 84 failed | 5 skipped | 10 failed as expected +assertions: 2209 | 2033 passed | 145 failed | 31 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index aa319412..e7568c60 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -13091,6 +13091,154 @@ with expansion: == There is no extra whitespace here +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( c_array ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( c_array ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types (differ in array N) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_3, !RangeEquals( array_int_4 ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_3, !UnorderedRangeEquals( array_int_4 ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers of different container types and value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Container conversions + Two equal containers, one random access, one not +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: +with message: + ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( + list_char_a ) + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, RangeEquals( list_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_int_a, UnorderedRangeEquals( list_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Value type + Two equal containers of different value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, RangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, UnorderedRangeEquals( vector_char_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Value type + Two non-equal containers of different value types +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, !RangeEquals( vector_char_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 2 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_int_a, !UnorderedRangeEquals( vector_char_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 2 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Ranges with begin that needs ADL +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + REQUIRE_THAT( a, !RangeEquals( b ) ) +with expansion: + { 1, 2, 3 } not elements are { 3, 2, 1 } + +MatchersRanges.tests.cpp:: PASSED: + REQUIRE_THAT( a, UnorderedRangeEquals( b ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 3, 2, 1 } + +------------------------------------------------------------------------------- +Type conversions of RangeEquals and similar + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, RangeEquals( array_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } elements are { 2, 3, 4 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 2, 3, 4 } + ------------------------------------------------------------------------------- Unexpected exceptions can be translated ------------------------------------------------------------------------------- @@ -13950,6 +14098,229 @@ MatchersRanges.tests.cpp:: PASSED: with expansion: !false +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Empty container matches empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, RangeEquals( empty_vector ) ) +with expansion: + { } elements are { } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Empty container does not match non-empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, !RangeEquals( non_empty_vector ) ) +with expansion: + { } not elements are { 1 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_vector, !RangeEquals( empty_vector ) ) +with expansion: + { 1 } not elements are { } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal 1-length non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_array, RangeEquals( non_empty_array ) ) +with expansion: + { 1 } elements are { 1 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal-sized, equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, RangeEquals( array_a ) ) +with expansion: + { 1, 2, 3 } elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two equal-sized, non-equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !RangeEquals( array_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 2, 2, 3 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !RangeEquals( array_c ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 2 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Basic usage + Two non-equal-sized, non-empty containers (with same first elements) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !RangeEquals( vector_b ) ) +with expansion: + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, RangeEquals( vector_a_plus_1, close_enough ) ) +with expansion: + { 1, 2, 3 } elements are { 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of RangeEquals range matcher + Custom predicate + Two non-equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !RangeEquals( vector_b, close_enough ) ) +with expansion: + { 1, 2, 3 } not elements are { 3, 3, 4 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Empty container matches empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, UnorderedRangeEquals( empty_vector ) ) +with expansion: + { } unordered elements are { } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Empty container does not match non-empty container +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( empty_vector, !UnorderedRangeEquals( non_empty_vector ) ) +with expansion: + { } not unordered elements are { 1 } + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_vector, !UnorderedRangeEquals( empty_vector ) ) +with expansion: + { 1 } not unordered elements are { } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal 1-length non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( non_empty_array, UnorderedRangeEquals( non_empty_array ) ) +with expansion: + { 1 } unordered elements are { 1 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal-sized, equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, UnorderedRangeEquals( array_a ) ) +with expansion: + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two equal-sized, non-equal, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( array_a, !UnorderedRangeEquals( array_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 2, 2, 3 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Basic usage + Two non-equal-sized, non-empty containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !UnorderedRangeEquals( vector_b ) ) +with expansion: + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Custom predicate + Two equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) ) +with expansion: + { 1, 10, 20 } unordered elements are { 11, 21, 2 } + +------------------------------------------------------------------------------- +Usage of UnorderedRangeEquals range matcher + Custom predicate + Two non-equal non-empty containers (close enough) +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp: +............................................................................... + +MatchersRanges.tests.cpp:: PASSED: + CHECK_THAT( vector_a, !UnorderedRangeEquals( vector_b, close_enough ) ) +with expansion: + { 1, 10, 21 } not unordered elements are { 11, 21, 3 } + ------------------------------------------------------------------------------- Usage of the SizeIs range matcher Some with stdlib containers @@ -17711,6 +18082,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 404 | 305 passed | 84 failed | 5 skipped | 10 failed as expected -assertions: 2173 | 1997 passed | 145 failed | 31 failed as expected +test cases: 407 | 308 passed | 84 failed | 5 skipped | 10 failed as expected +assertions: 2209 | 2033 passed | 145 failed | 31 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 5908fe2c..fa16f55b 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -1367,6 +1367,14 @@ at Exception.tests.cpp: + + + + + + + + FAILED: @@ -1415,6 +1423,22 @@ at Exception.tests.cpp: + + + + + + + + + + + + + + + + diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 5a82d087..bb3ad3ea 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -1366,6 +1366,14 @@ at Exception.tests.cpp: + + + + + + + + FAILED: @@ -1414,6 +1422,22 @@ at Exception.tests.cpp: + + + + + + + + + + + + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index fcf21a1c..315bf6bd 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -1365,6 +1365,14 @@ at Matchers.tests.cpp: + + + + + + + + @@ -1404,6 +1412,22 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index fdf890e2..f916f324 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -1364,6 +1364,14 @@ at Matchers.tests.cpp: + + + + + + + + @@ -1403,6 +1411,22 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + + + + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index a8b3b693..2783ebba 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -3223,6 +3223,40 @@ ok {test-number} - trim(StringRef(leading_whitespace)) == StringRef(no_whitespac ok {test-number} - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here # Trim strings ok {test-number} - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_3, !UnorderedRangeEquals( array_int_4 ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - with 1 message: 'ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( list_char_a )' +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( list_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( list_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, !RangeEquals( vector_char_b ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, !UnorderedRangeEquals( vector_char_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 2 } +# Type conversions of RangeEquals and similar +ok {test-number} - a, !RangeEquals( b ) for: { 1, 2, 3 } not elements are { 3, 2, 1 } +# Type conversions of RangeEquals and similar +ok {test-number} - a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated not ok {test-number} - unexpected exception with message: '3.14' # Upcasting special member functions @@ -3433,6 +3467,44 @@ ok {test-number} - mocked.m_derefed[2] for: true ok {test-number} - !(mocked.m_derefed[3]) for: !false # Usage of NoneTrue range matcher ok {test-number} - !(mocked.m_derefed[4]) for: !false +# Usage of RangeEquals range matcher +ok {test-number} - empty_vector, RangeEquals( empty_vector ) for: { } elements are { } +# Usage of RangeEquals range matcher +ok {test-number} - empty_vector, !RangeEquals( non_empty_vector ) for: { } not elements are { 1 } +# Usage of RangeEquals range matcher +ok {test-number} - non_empty_vector, !RangeEquals( empty_vector ) for: { 1 } not elements are { } +# Usage of RangeEquals range matcher +ok {test-number} - non_empty_array, RangeEquals( non_empty_array ) for: { 1 } elements are { 1 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, RangeEquals( array_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, !RangeEquals( array_b ) for: { 1, 2, 3 } not elements are { 2, 2, 3 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, !RangeEquals( array_c ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, !RangeEquals( vector_b ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, RangeEquals( vector_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, !RangeEquals( vector_b, close_enough ) for: { 1, 2, 3 } not elements are { 3, 3, 4 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - empty_vector, UnorderedRangeEquals( empty_vector ) for: { } unordered elements are { } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - empty_vector, !UnorderedRangeEquals( non_empty_vector ) for: { } not unordered elements are { 1 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - non_empty_vector, !UnorderedRangeEquals( empty_vector ) for: { 1 } not unordered elements are { } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - non_empty_array, UnorderedRangeEquals( non_empty_array ) for: { 1 } unordered elements are { 1 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - array_a, UnorderedRangeEquals( array_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - array_a, !UnorderedRangeEquals( array_b ) for: { 1, 2, 3 } not unordered elements are { 2, 2, 3 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, !UnorderedRangeEquals( vector_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) for: { 1, 10, 20 } unordered elements are { 11, 21, 2 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, !UnorderedRangeEquals( vector_b, close_enough ) for: { 1, 10, 21 } not unordered elements are { 11, 21, 3 } # Usage of the SizeIs range matcher ok {test-number} - empty_vec, SizeIs(0) for: { } has size == 0 # Usage of the SizeIs range matcher @@ -4371,5 +4443,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2184 +1..2220 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index ad69ec76..49c4b5e9 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -3216,6 +3216,40 @@ ok {test-number} - trim(StringRef(leading_whitespace)) == StringRef(no_whitespac ok {test-number} - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here # Trim strings ok {test-number} - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_3, !UnorderedRangeEquals( array_int_4 ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - with 1 message: 'ContainerIsRandomAccess( array_int_a ) != ContainerIsRandomAccess( list_char_a )' +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, RangeEquals( list_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - array_int_a, UnorderedRangeEquals( list_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, RangeEquals( vector_char_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, UnorderedRangeEquals( vector_char_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, !RangeEquals( vector_char_b ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_int_a, !UnorderedRangeEquals( vector_char_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 2 } +# Type conversions of RangeEquals and similar +ok {test-number} - a, !RangeEquals( b ) for: { 1, 2, 3 } not elements are { 3, 2, 1 } +# Type conversions of RangeEquals and similar +ok {test-number} - a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +# Type conversions of RangeEquals and similar +ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated not ok {test-number} - unexpected exception with message: '3.14' # Upcasting special member functions @@ -3426,6 +3460,44 @@ ok {test-number} - mocked.m_derefed[2] for: true ok {test-number} - !(mocked.m_derefed[3]) for: !false # Usage of NoneTrue range matcher ok {test-number} - !(mocked.m_derefed[4]) for: !false +# Usage of RangeEquals range matcher +ok {test-number} - empty_vector, RangeEquals( empty_vector ) for: { } elements are { } +# Usage of RangeEquals range matcher +ok {test-number} - empty_vector, !RangeEquals( non_empty_vector ) for: { } not elements are { 1 } +# Usage of RangeEquals range matcher +ok {test-number} - non_empty_vector, !RangeEquals( empty_vector ) for: { 1 } not elements are { } +# Usage of RangeEquals range matcher +ok {test-number} - non_empty_array, RangeEquals( non_empty_array ) for: { 1 } elements are { 1 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, RangeEquals( array_a ) for: { 1, 2, 3 } elements are { 1, 2, 3 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, !RangeEquals( array_b ) for: { 1, 2, 3 } not elements are { 2, 2, 3 } +# Usage of RangeEquals range matcher +ok {test-number} - array_a, !RangeEquals( array_c ) for: { 1, 2, 3 } not elements are { 1, 2, 2 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, !RangeEquals( vector_b ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, RangeEquals( vector_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } +# Usage of RangeEquals range matcher +ok {test-number} - vector_a, !RangeEquals( vector_b, close_enough ) for: { 1, 2, 3 } not elements are { 3, 3, 4 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - empty_vector, UnorderedRangeEquals( empty_vector ) for: { } unordered elements are { } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - empty_vector, !UnorderedRangeEquals( non_empty_vector ) for: { } not unordered elements are { 1 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - non_empty_vector, !UnorderedRangeEquals( empty_vector ) for: { 1 } not unordered elements are { } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - non_empty_array, UnorderedRangeEquals( non_empty_array ) for: { 1 } unordered elements are { 1 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - array_a, UnorderedRangeEquals( array_a ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - array_a, !UnorderedRangeEquals( array_b ) for: { 1, 2, 3 } not unordered elements are { 2, 2, 3 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, !UnorderedRangeEquals( vector_b ) for: { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) for: { 1, 10, 20 } unordered elements are { 11, 21, 2 } +# Usage of UnorderedRangeEquals range matcher +ok {test-number} - vector_a, !UnorderedRangeEquals( vector_b, close_enough ) for: { 1, 10, 21 } not unordered elements are { 11, 21, 3 } # Usage of the SizeIs range matcher ok {test-number} - empty_vec, SizeIs(0) for: { } has size == 0 # Usage of the SizeIs range matcher @@ -4360,5 +4432,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2184 +1..2220 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index df406058..9fadcf98 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -646,6 +646,8 @@ ##teamcity[testFinished name='Tracker' duration="{duration}"] ##teamcity[testStarted name='Trim strings'] ##teamcity[testFinished name='Trim strings' duration="{duration}"] +##teamcity[testStarted name='Type conversions of RangeEquals and similar'] +##teamcity[testFinished name='Type conversions of RangeEquals and similar' duration="{duration}"] ##teamcity[testStarted name='Unexpected exceptions can be translated'] ##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] @@ -663,6 +665,10 @@ ##teamcity[testFinished name='Usage of NoneMatch range matcher' duration="{duration}"] ##teamcity[testStarted name='Usage of NoneTrue range matcher'] ##teamcity[testFinished name='Usage of NoneTrue range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of RangeEquals range matcher'] +##teamcity[testFinished name='Usage of RangeEquals range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of UnorderedRangeEquals range matcher'] +##teamcity[testFinished name='Usage of UnorderedRangeEquals range matcher' duration="{duration}"] ##teamcity[testStarted name='Usage of the SizeIs range matcher'] ##teamcity[testFinished name='Usage of the SizeIs range matcher' duration="{duration}"] ##teamcity[testStarted name='Use a custom approx'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 1aea9f9b..69fc2791 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -646,6 +646,8 @@ ##teamcity[testFinished name='Tracker' duration="{duration}"] ##teamcity[testStarted name='Trim strings'] ##teamcity[testFinished name='Trim strings' duration="{duration}"] +##teamcity[testStarted name='Type conversions of RangeEquals and similar'] +##teamcity[testFinished name='Type conversions of RangeEquals and similar' duration="{duration}"] ##teamcity[testStarted name='Unexpected exceptions can be translated'] ##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] @@ -663,6 +665,10 @@ ##teamcity[testFinished name='Usage of NoneMatch range matcher' duration="{duration}"] ##teamcity[testStarted name='Usage of NoneTrue range matcher'] ##teamcity[testFinished name='Usage of NoneTrue range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of RangeEquals range matcher'] +##teamcity[testFinished name='Usage of RangeEquals range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of UnorderedRangeEquals range matcher'] +##teamcity[testFinished name='Usage of UnorderedRangeEquals range matcher' duration="{duration}"] ##teamcity[testStarted name='Usage of the SizeIs range matcher'] ##teamcity[testFinished name='Usage of the SizeIs range matcher' duration="{duration}"] ##teamcity[testStarted name='Use a custom approx'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 8db89151..b5401a46 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -15253,6 +15253,182 @@ There is no extra whitespace here + +
+
+ + + array_int_a, RangeEquals( c_array ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( c_array ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_int_3, !RangeEquals( array_int_4 ) + + + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + + + + + array_int_3, !UnorderedRangeEquals( array_int_4 ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + array_int_a, RangeEquals( vector_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( vector_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_int_a, RangeEquals( list_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( list_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + vector_int_a, RangeEquals( vector_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + vector_int_a, UnorderedRangeEquals( vector_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + vector_int_a, !RangeEquals( vector_char_b ) + + + { 1, 2, 3 } not elements are { 1, 2, 2 } + + + + + vector_int_a, !UnorderedRangeEquals( vector_char_b ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 2 } + + + +
+ +
+
+ + + a, !RangeEquals( b ) + + + { 1, 2, 3 } not elements are { 3, 2, 1 } + + + + + a, UnorderedRangeEquals( b ) + + + { 1, 2, 3 } unordered elements are { 3, 2, 1 } + + + +
+
+
+ + + vector_a, RangeEquals( array_a_plus_1, close_enough ) + + + { 1, 2, 3 } elements are { 2, 3, 4 } + + + + + vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) + + + { 1, 2, 3 } unordered elements are { 2, 3, 4 } + + + +
+ +
+ +
3.14 @@ -16334,6 +16510,260 @@ There is no extra whitespace here + +
+
+ + + empty_vector, RangeEquals( empty_vector ) + + + { } elements are { } + + + +
+ +
+
+
+ + + empty_vector, !RangeEquals( non_empty_vector ) + + + { } not elements are { 1 } + + + + + non_empty_vector, !RangeEquals( empty_vector ) + + + { 1 } not elements are { } + + + +
+ +
+
+
+ + + non_empty_array, RangeEquals( non_empty_array ) + + + { 1 } elements are { 1 } + + + +
+ +
+
+
+ + + array_a, RangeEquals( array_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_a, !RangeEquals( array_b ) + + + { 1, 2, 3 } not elements are { 2, 2, 3 } + + + + + array_a, !RangeEquals( array_c ) + + + { 1, 2, 3 } not elements are { 1, 2, 2 } + + + +
+ +
+
+
+ + + vector_a, !RangeEquals( vector_b ) + + + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, RangeEquals( vector_a_plus_1, close_enough ) + + + { 1, 2, 3 } elements are { 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, !RangeEquals( vector_b, close_enough ) + + + { 1, 2, 3 } not elements are { 3, 3, 4 } + + + +
+ +
+ +
+ +
+
+ + + empty_vector, UnorderedRangeEquals( empty_vector ) + + + { } unordered elements are { } + + + +
+ +
+
+
+ + + empty_vector, !UnorderedRangeEquals( non_empty_vector ) + + + { } not unordered elements are { 1 } + + + + + non_empty_vector, !UnorderedRangeEquals( empty_vector ) + + + { 1 } not unordered elements are { } + + + +
+ +
+
+
+ + + non_empty_array, UnorderedRangeEquals( non_empty_array ) + + + { 1 } unordered elements are { 1 } + + + +
+ +
+
+
+ + + array_a, UnorderedRangeEquals( array_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_a, !UnorderedRangeEquals( array_b ) + + + { 1, 2, 3 } not unordered elements are { 2, 2, 3 } + + + +
+ +
+
+
+ + + vector_a, !UnorderedRangeEquals( vector_b ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) + + + { 1, 10, 20 } unordered elements are { 11, 21, 2 } + + + +
+ +
+
+
+ + + vector_a, !UnorderedRangeEquals( vector_b, close_enough ) + + + { 1, 10, 21 } not unordered elements are { 11, 21, 3 } + + + +
+ +
+ +
@@ -20612,6 +21042,6 @@ b1!
- - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 08e7e6b4..dd8dc0f0 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -15253,6 +15253,182 @@ There is no extra whitespace here
+ +
+
+ + + array_int_a, RangeEquals( c_array ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( c_array ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_int_3, !RangeEquals( array_int_4 ) + + + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + + + + + array_int_3, !UnorderedRangeEquals( array_int_4 ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + array_int_a, RangeEquals( vector_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( vector_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_int_a, RangeEquals( list_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + array_int_a, UnorderedRangeEquals( list_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + vector_int_a, RangeEquals( vector_char_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + + + vector_int_a, UnorderedRangeEquals( vector_char_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + vector_int_a, !RangeEquals( vector_char_b ) + + + { 1, 2, 3 } not elements are { 1, 2, 2 } + + + + + vector_int_a, !UnorderedRangeEquals( vector_char_b ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 2 } + + + +
+ +
+
+ + + a, !RangeEquals( b ) + + + { 1, 2, 3 } not elements are { 3, 2, 1 } + + + + + a, UnorderedRangeEquals( b ) + + + { 1, 2, 3 } unordered elements are { 3, 2, 1 } + + + +
+
+
+ + + vector_a, RangeEquals( array_a_plus_1, close_enough ) + + + { 1, 2, 3 } elements are { 2, 3, 4 } + + + + + vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) + + + { 1, 2, 3 } unordered elements are { 2, 3, 4 } + + + +
+ +
+ +
3.14 @@ -16334,6 +16510,260 @@ There is no extra whitespace here + +
+
+ + + empty_vector, RangeEquals( empty_vector ) + + + { } elements are { } + + + +
+ +
+
+
+ + + empty_vector, !RangeEquals( non_empty_vector ) + + + { } not elements are { 1 } + + + + + non_empty_vector, !RangeEquals( empty_vector ) + + + { 1 } not elements are { } + + + +
+ +
+
+
+ + + non_empty_array, RangeEquals( non_empty_array ) + + + { 1 } elements are { 1 } + + + +
+ +
+
+
+ + + array_a, RangeEquals( array_a ) + + + { 1, 2, 3 } elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_a, !RangeEquals( array_b ) + + + { 1, 2, 3 } not elements are { 2, 2, 3 } + + + + + array_a, !RangeEquals( array_c ) + + + { 1, 2, 3 } not elements are { 1, 2, 2 } + + + +
+ +
+
+
+ + + vector_a, !RangeEquals( vector_b ) + + + { 1, 2, 3 } not elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, RangeEquals( vector_a_plus_1, close_enough ) + + + { 1, 2, 3 } elements are { 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, !RangeEquals( vector_b, close_enough ) + + + { 1, 2, 3 } not elements are { 3, 3, 4 } + + + +
+ +
+ +
+ +
+
+ + + empty_vector, UnorderedRangeEquals( empty_vector ) + + + { } unordered elements are { } + + + +
+ +
+
+
+ + + empty_vector, !UnorderedRangeEquals( non_empty_vector ) + + + { } not unordered elements are { 1 } + + + + + non_empty_vector, !UnorderedRangeEquals( empty_vector ) + + + { 1 } not unordered elements are { } + + + +
+ +
+
+
+ + + non_empty_array, UnorderedRangeEquals( non_empty_array ) + + + { 1 } unordered elements are { 1 } + + + +
+ +
+
+
+ + + array_a, UnorderedRangeEquals( array_a ) + + + { 1, 2, 3 } unordered elements are { 1, 2, 3 } + + + +
+ +
+
+
+ + + array_a, !UnorderedRangeEquals( array_b ) + + + { 1, 2, 3 } not unordered elements are { 2, 2, 3 } + + + +
+ +
+
+
+ + + vector_a, !UnorderedRangeEquals( vector_b ) + + + { 1, 2, 3 } not unordered elements are { 1, 2, 3, 4 } + + + +
+ +
+
+
+ + + vector_a, UnorderedRangeEquals( vector_a_plus_1, close_enough ) + + + { 1, 10, 20 } unordered elements are { 11, 21, 2 } + + + +
+ +
+
+
+ + + vector_a, !UnorderedRangeEquals( vector_b, close_enough ) + + + { 1, 10, 21 } not unordered elements are { 11, 21, 3 } + + + +
+ +
+ +
@@ -20611,6 +21041,6 @@ b1!
- - + + diff --git a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp index f30af703..02186783 100644 --- a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +++ b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -832,3 +833,225 @@ TEST_CASE( "The quantifier range matchers support types with different types ret } #endif + +TEST_CASE( "Usage of RangeEquals range matcher", "[matchers][templated][quantifiers]" ) { + using Catch::Matchers::RangeEquals; + + // In these tests, the types are always the same - type conversion is in the next section + SECTION( "Basic usage" ) { + SECTION( "Empty container matches empty container" ) { + const std::vector empty_vector; + CHECK_THAT( empty_vector, RangeEquals( empty_vector ) ); + } + SECTION( "Empty container does not match non-empty container" ) { + const std::vector empty_vector; + const std::vector non_empty_vector{ 1 }; + CHECK_THAT( empty_vector, !RangeEquals( non_empty_vector ) ); + // ...and in reverse + CHECK_THAT( non_empty_vector, !RangeEquals( empty_vector ) ); + } + SECTION( "Two equal 1-length non-empty containers" ) { + const std::array non_empty_array{ { 1 } }; + CHECK_THAT( non_empty_array, RangeEquals( non_empty_array ) ); + } + SECTION( "Two equal-sized, equal, non-empty containers" ) { + const std::array array_a{ { 1, 2, 3 } }; + CHECK_THAT( array_a, RangeEquals( array_a ) ); + } + SECTION( "Two equal-sized, non-equal, non-empty containers" ) { + const std::array array_a{ { 1, 2, 3 } }; + const std::array array_b{ { 2, 2, 3 } }; + const std::array array_c{ { 1, 2, 2 } }; + CHECK_THAT( array_a, !RangeEquals( array_b ) ); + CHECK_THAT( array_a, !RangeEquals( array_c ) ); + } + SECTION( "Two non-equal-sized, non-empty containers (with same first " + "elements)" ) { + const std::vector vector_a{ 1, 2, 3 }; + const std::vector vector_b{ 1, 2, 3, 4 }; + CHECK_THAT( vector_a, !RangeEquals( vector_b ) ); + } + } + + SECTION( "Custom predicate" ) { + + auto close_enough = []( int lhs, int rhs ) { + return std::abs( lhs - rhs ) <= 1; + }; + + SECTION( "Two equal non-empty containers (close enough)" ) { + const std::vector vector_a{ { 1, 2, 3 } }; + const std::vector vector_a_plus_1{ { 2, 3, 4 } }; + CHECK_THAT( vector_a, RangeEquals( vector_a_plus_1, close_enough ) ); + } + SECTION( "Two non-equal non-empty containers (close enough)" ) { + const std::vector vector_a{ { 1, 2, 3 } }; + const std::vector vector_b{ { 3, 3, 4 } }; + CHECK_THAT( vector_a, !RangeEquals( vector_b, close_enough ) ); + } + } + + // Cannot usefully test short-circuits, as the complexiy of std::equal is + // only guaranteed to be O(n) or better (even if many implementations + // short-circuit if the range lengths differ for + // LegacyRandomAccessIterators) +} + +TEST_CASE( "Usage of UnorderedRangeEquals range matcher", + "[matchers][templated][quantifiers]" ) { + using Catch::Matchers::UnorderedRangeEquals; + + // In these tests, the types are always the same - type conversion is in the + // next section + SECTION( "Basic usage" ) { + SECTION( "Empty container matches empty container" ) { + const std::vector empty_vector; + CHECK_THAT( empty_vector, UnorderedRangeEquals( empty_vector ) ); + } + SECTION( "Empty container does not match non-empty container" ) { + const std::vector empty_vector; + const std::vector non_empty_vector{ 1 }; + CHECK_THAT( empty_vector, + !UnorderedRangeEquals( non_empty_vector ) ); + // ...and in reverse + CHECK_THAT( non_empty_vector, + !UnorderedRangeEquals( empty_vector ) ); + } + SECTION( "Two equal 1-length non-empty containers" ) { + const std::array non_empty_array{ { 1 } }; + CHECK_THAT( non_empty_array, + UnorderedRangeEquals( non_empty_array ) ); + } + SECTION( "Two equal-sized, equal, non-empty containers" ) { + const std::array array_a{ { 1, 2, 3 } }; + CHECK_THAT( array_a, UnorderedRangeEquals( array_a ) ); + } + SECTION( "Two equal-sized, non-equal, non-empty containers" ) { + const std::array array_a{ { 1, 2, 3 } }; + const std::array array_b{ { 2, 2, 3 } }; + CHECK_THAT( array_a, !UnorderedRangeEquals( array_b ) ); + } + SECTION( "Two non-equal-sized, non-empty containers" ) { + const std::vector vector_a{ 1, 2, 3 }; + const std::vector vector_b{ 1, 2, 3, 4 }; + CHECK_THAT( vector_a, !UnorderedRangeEquals( vector_b ) ); + } + } + + SECTION( "Custom predicate" ) { + + auto close_enough = []( int lhs, int rhs ) { + return std::abs( lhs - rhs ) <= 1; + }; + + SECTION( "Two equal non-empty containers (close enough)" ) { + const std::vector vector_a{ { 1, 10, 20 } }; + const std::vector vector_a_plus_1{ { 11, 21, 2 } }; + CHECK_THAT( vector_a, + UnorderedRangeEquals( vector_a_plus_1, close_enough ) ); + } + SECTION( "Two non-equal non-empty containers (close enough)" ) { + const std::vector vector_a{ { 1, 10, 21 } }; + const std::vector vector_b{ { 11, 21, 3 } }; + CHECK_THAT( vector_a, + !UnorderedRangeEquals( vector_b, close_enough ) ); + } + } + + // As above with RangeEquals, short cicuiting and other optimisations + // are left to the STL implementation +} + +/** + * Return true if the type given has a random access iterator type. + */ +template +static constexpr bool ContainerIsRandomAccess( const Container& ) { + using array_iter_category = typename std::iterator_traits< + typename Container::iterator>::iterator_category; + + return std::is_base_of::value; +} + +TEST_CASE( "Type conversions of RangeEquals and similar", + "[matchers][templated][quantifiers]" ) { + using Catch::Matchers::RangeEquals; + using Catch::Matchers::UnorderedRangeEquals; + + // In these test, we can always test RangeEquals and + // UnorderedRangeEquals in the same way, since we're mostly + // testing the template type deductions (and RangeEquals + // implies UnorderedRangeEquals) + + SECTION( "Container conversions" ) { + SECTION( "Two equal containers of different container types" ) { + const std::array array_int_a{ { 1, 2, 3 } }; + const int c_array[3] = { 1, 2, 3 }; + CHECK_THAT( array_int_a, RangeEquals( c_array ) ); + CHECK_THAT( array_int_a, UnorderedRangeEquals( c_array ) ); + } + SECTION( "Two equal containers of different container types " + "(differ in array N)" ) { + const std::array array_int_3{ { 1, 2, 3 } }; + const std::array array_int_4{ { 1, 2, 3, 4 } }; + CHECK_THAT( array_int_3, !RangeEquals( array_int_4 ) ); + CHECK_THAT( array_int_3, !UnorderedRangeEquals( array_int_4 ) ); + } + SECTION( "Two equal containers of different container types and value " + "types" ) { + const std::array array_int_a{ { 1, 2, 3 } }; + const std::vector vector_char_a{ 1, 2, 3 }; + CHECK_THAT( array_int_a, RangeEquals( vector_char_a ) ); + CHECK_THAT( array_int_a, UnorderedRangeEquals( vector_char_a ) ); + } + SECTION( "Two equal containers, one random access, one not" ) { + const std::array array_int_a{ { 1, 2, 3 } }; + const std::list list_char_a{ 1, 2, 3 }; + + // Verify these types really are different in random access nature + STATIC_REQUIRE( ContainerIsRandomAccess( array_int_a ) != + ContainerIsRandomAccess( list_char_a ) ); + + CHECK_THAT( array_int_a, RangeEquals( list_char_a ) ); + CHECK_THAT( array_int_a, UnorderedRangeEquals( list_char_a ) ); + } + } + + SECTION( "Value type" ) { + SECTION( "Two equal containers of different value types" ) { + const std::vector vector_int_a{ 1, 2, 3 }; + const std::vector vector_char_a{ 1, 2, 3 }; + CHECK_THAT( vector_int_a, RangeEquals( vector_char_a ) ); + CHECK_THAT( vector_int_a, UnorderedRangeEquals( vector_char_a ) ); + } + SECTION( "Two non-equal containers of different value types" ) { + const std::vector vector_int_a{ 1, 2, 3 }; + const std::vector vector_char_b{ 1, 2, 2 }; + CHECK_THAT( vector_int_a, !RangeEquals( vector_char_b ) ); + CHECK_THAT( vector_int_a, !UnorderedRangeEquals( vector_char_b ) ); + } + } + + SECTION( "Ranges with begin that needs ADL" ) { + unrelated::needs_ADL_begin a{ 1, 2, 3 }, b{ 3, 2, 1 }; + REQUIRE_THAT( a, !RangeEquals( b ) ); + REQUIRE_THAT( a, UnorderedRangeEquals( b ) ); + } + + SECTION( "Custom predicate" ) { + + auto close_enough = []( int lhs, int rhs ) { + return std::abs( lhs - rhs ) <= 1; + }; + + SECTION( "Two equal non-empty containers (close enough)" ) { + const std::vector vector_a{ { 1, 2, 3 } }; + const std::array array_a_plus_1{ { 2, 3, 4 } }; + CHECK_THAT( vector_a, + RangeEquals( array_a_plus_1, close_enough ) ); + CHECK_THAT( vector_a, + UnorderedRangeEquals( array_a_plus_1, close_enough ) ); + } + } +} \ No newline at end of file