Skip to content

Commit 0a57ec3

Browse files
committed
Update the apply_permutation tests to use the BOOST_CHECK_EQUAL_COLLECTIONS facilities. Based on boostorg#42 Thanks to Jeremy for the patch
1 parent 9477cd8 commit 0a57ec3

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

test/apply_permutation_test.cpp

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414

1515
#define BOOST_TEST_MAIN
1616

17-
#include <boost/test/unit_test.hpp>
17+
#include <boost/test/included/unit_test.hpp>
1818

1919
namespace ba = boost::algorithm;
2020

2121

22-
void test_apply_permutation()
22+
BOOST_AUTO_TEST_CASE(test_apply_permutation)
2323
{
2424
//Empty
2525
{
2626
std::vector<int> vec, order, result;
2727

2828
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
29-
BOOST_CHECK(vec == result);
29+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
3030
}
3131
//1 element
3232
{
@@ -36,7 +36,7 @@ void test_apply_permutation()
3636
result = vec;
3737

3838
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
39-
BOOST_CHECK(vec == result);
39+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
4040
}
4141
//2 elements, no changes
4242
{
@@ -46,7 +46,7 @@ void test_apply_permutation()
4646
result = vec;
4747

4848
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
49-
BOOST_CHECK(vec == result);
49+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
5050
}
5151
//2 elements, changed
5252
{
@@ -56,7 +56,7 @@ void test_apply_permutation()
5656
result.push_back(2); result.push_back(1);
5757

5858
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
59-
BOOST_CHECK(vec == result);
59+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
6060
}
6161
//Multiple elements, no changes
6262
{
@@ -66,7 +66,7 @@ void test_apply_permutation()
6666
result = vec;
6767

6868
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
69-
BOOST_CHECK(vec == result);
69+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
7070
}
7171
//Multiple elements, changed
7272
{
@@ -76,7 +76,7 @@ void test_apply_permutation()
7676
result.push_back(5); result.push_back(4); result.push_back(3); result.push_back(2); result.push_back(1);
7777

7878
ba::apply_permutation(vec.begin(), vec.end(), order.begin(), order.end());
79-
BOOST_CHECK(vec == result);
79+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
8080
}
8181
//Just test range interface
8282
{
@@ -86,18 +86,18 @@ void test_apply_permutation()
8686
result = vec;
8787

8888
ba::apply_permutation(vec, order);
89-
BOOST_CHECK(vec == result);
89+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
9090
}
9191
}
9292

93-
void test_apply_reverse_permutation()
93+
BOOST_AUTO_TEST_CASE(test_apply_reverse_permutation)
9494
{
9595
//Empty
9696
{
9797
std::vector<int> vec, order, result;
9898

9999
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
100-
BOOST_CHECK(vec == result);
100+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
101101
}
102102
//1 element
103103
{
@@ -107,7 +107,7 @@ void test_apply_reverse_permutation()
107107
result = vec;
108108

109109
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
110-
BOOST_CHECK(vec == result);
110+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
111111
}
112112
//2 elements, no changes
113113
{
@@ -117,7 +117,7 @@ void test_apply_reverse_permutation()
117117
result = vec;
118118

119119
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
120-
BOOST_CHECK(vec == result);
120+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
121121
}
122122
//2 elements, changed
123123
{
@@ -127,7 +127,7 @@ void test_apply_reverse_permutation()
127127
result.push_back(2); result.push_back(1);
128128

129129
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
130-
BOOST_CHECK(vec == result);
130+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
131131
}
132132
//Multiple elements, no changes
133133
{
@@ -137,7 +137,7 @@ void test_apply_reverse_permutation()
137137
result = vec;
138138

139139
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
140-
BOOST_CHECK(vec == result);
140+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
141141
}
142142
//Multiple elements, changed
143143
{
@@ -147,7 +147,7 @@ void test_apply_reverse_permutation()
147147
result.push_back(5); result.push_back(4); result.push_back(3); result.push_back(2); result.push_back(1);
148148

149149
ba::apply_reverse_permutation(vec.begin(), vec.end(), order.begin(), order.end());
150-
BOOST_CHECK(vec == result);
150+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
151151
}
152152
//Just test range interface
153153
{
@@ -157,12 +157,6 @@ void test_apply_reverse_permutation()
157157
result = vec;
158158

159159
ba::apply_reverse_permutation(vec, order);
160-
BOOST_CHECK(vec == result);
160+
BOOST_CHECK_EQUAL_COLLECTIONS(vec.begin(), vec.end(), result.begin(), result.end());
161161
}
162162
}
163-
164-
BOOST_AUTO_TEST_CASE(test_main)
165-
{
166-
test_apply_permutation();
167-
test_apply_reverse_permutation();
168-
}

0 commit comments

Comments
 (0)