From 0a57ec30a2bc889bfcbbdb9df901125f50d81516 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 3 Jul 2019 07:44:25 -0700 Subject: [PATCH] Update the apply_permutation tests to use the BOOST_CHECK_EQUAL_COLLECTIONS facilities. Based on https://github.com/boostorg/algorithm/pull/42 Thanks to Jeremy for the patch --- test/apply_permutation_test.cpp | 40 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/test/apply_permutation_test.cpp b/test/apply_permutation_test.cpp index 3dbb7e1..94a60ac 100644 --- a/test/apply_permutation_test.cpp +++ b/test/apply_permutation_test.cpp @@ -14,19 +14,19 @@ #define BOOST_TEST_MAIN -#include +#include namespace ba = boost::algorithm; -void test_apply_permutation() +BOOST_AUTO_TEST_CASE(test_apply_permutation) { //Empty { std::vector vec, order, result; ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //1 element { @@ -36,7 +36,7 @@ void test_apply_permutation() result = vec; ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //2 elements, no changes { @@ -46,7 +46,7 @@ void test_apply_permutation() result = vec; ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //2 elements, changed { @@ -56,7 +56,7 @@ void test_apply_permutation() result.push_back(2); result.push_back(1); ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Multiple elements, no changes { @@ -66,7 +66,7 @@ void test_apply_permutation() result = vec; ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Multiple elements, changed { @@ -76,7 +76,7 @@ void test_apply_permutation() result.push_back(5); result.push_back(4); result.push_back(3); result.push_back(2); result.push_back(1); ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Just test range interface { @@ -86,18 +86,18 @@ void test_apply_permutation() result = vec; ba::apply_permutation(vec, order); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } } -void test_apply_reverse_permutation() +BOOST_AUTO_TEST_CASE(test_apply_reverse_permutation) { //Empty { std::vector vec, order, result; ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //1 element { @@ -107,7 +107,7 @@ void test_apply_reverse_permutation() result = vec; ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //2 elements, no changes { @@ -117,7 +117,7 @@ void test_apply_reverse_permutation() result = vec; ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //2 elements, changed { @@ -127,7 +127,7 @@ void test_apply_reverse_permutation() result.push_back(2); result.push_back(1); ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Multiple elements, no changes { @@ -137,7 +137,7 @@ void test_apply_reverse_permutation() result = vec; ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Multiple elements, changed { @@ -147,7 +147,7 @@ void test_apply_reverse_permutation() result.push_back(5); result.push_back(4); result.push_back(3); result.push_back(2); result.push_back(1); ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end()); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } //Just test range interface { @@ -157,12 +157,6 @@ void test_apply_reverse_permutation() result = vec; ba::apply_reverse_permutation(vec, order); - BOOST_CHECK(vec == result); + BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end()); } } - -BOOST_AUTO_TEST_CASE(test_main) -{ - test_apply_permutation(); - test_apply_reverse_permutation(); -}