Skip to content

Commit 16077c9

Browse files
committed
const-qualify more collections in MOP tests
1 parent afaec37 commit 16077c9

File tree

12 files changed

+47
-47
lines changed

12 files changed

+47
-47
lines changed

tests/probes/block.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2022 Morwenn
2+
* Copyright (c) 2021-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -17,7 +17,7 @@ TEST_CASE( "presortedness measure: block", "[probe][block]" )
1717

1818
SECTION( "simple test" )
1919
{
20-
std::forward_list<int> li = { 74, 59, 62, 23, 86, 69, 18, 52, 77, 68 };
20+
const std::forward_list<int> li = { 74, 59, 62, 23, 86, 69, 18, 52, 77, 68 };
2121
CHECK( block(li) == 8 );
2222
CHECK( block(li.begin(), li.end()) == 8 );
2323

@@ -30,7 +30,7 @@ TEST_CASE( "presortedness measure: block", "[probe][block]" )
3030
// The upper bound should correspond to the size of
3131
// the input sequence minus one
3232

33-
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
33+
const std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
3434
auto max_n = block.max_for_size(cppsort::utility::size(li));
3535
CHECK( max_n == 10 );
3636
CHECK( block(li) == max_n );

tests/probes/dis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -16,19 +16,19 @@ TEST_CASE( "presortedness measure: dis", "[probe][dis]" )
1616
SECTION( "simple tests" )
1717
{
1818
{
19-
std::forward_list<int> li = { 47, 53, 46, 41, 59, 81, 74, 97, 100, 45 };
19+
const std::forward_list<int> li = { 47, 53, 46, 41, 59, 81, 74, 97, 100, 45 };
2020
CHECK( dis(li) == 9 );
2121
CHECK( dis(li.begin(), li.end()) == 9 );
2222

23-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
23+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
2424
CHECK( dis(tricky, &internal_compare<int>::compare_to) == 9 );
2525
}
2626
{
2727
const std::forward_list<int> li = { 48, 43, 96, 44, 42, 34, 42, 57, 68, 69 };
2828
CHECK( dis(li) == 7 );
2929
CHECK( dis(li.begin(), li.end()) == 7 );
3030

31-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
31+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
3232
CHECK( dis(tricky, &internal_compare<int>::compare_to) == 7 );
3333
}
3434
}
@@ -52,7 +52,7 @@ TEST_CASE( "presortedness measure: dis", "[probe][dis]" )
5252
// The upper bound should correspond to the size of
5353
// the input sequence minus one
5454

55-
std::forward_list<int> li = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
55+
const std::forward_list<int> li = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
5656
auto max_n = dis.max_for_size(cppsort::utility::size(li));
5757
CHECK( max_n == 10 );
5858
CHECK( dis(li) == max_n );

tests/probes/enc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -15,7 +15,7 @@ TEST_CASE( "presortedness measure: enc", "[probe][enc]" )
1515

1616
SECTION( "simple test" )
1717
{
18-
std::forward_list<int> li = { 4, 6, 5, 2, 9, 1, 3, 8, 0, 7 };
18+
const std::forward_list<int> li = { 4, 6, 5, 2, 9, 1, 3, 8, 0, 7 };
1919
CHECK( enc(li) == 2 );
2020
CHECK( enc(li.begin(), li.end()) == 2 );
2121

@@ -28,7 +28,7 @@ TEST_CASE( "presortedness measure: enc", "[probe][enc]" )
2828
// The upper bound should correspond to half the size
2929
// of the input sequence minus one
3030

31-
std::forward_list<int> li = { 10, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 };
31+
const std::forward_list<int> li = { 10, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5 };
3232
auto max_n = enc.max_for_size(cppsort::utility::size(li));
3333
CHECK( max_n == 5 );
3434
CHECK( enc(li) == max_n );

tests/probes/every_probe_common.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEMPLATE_TEST_CASE( "test every probe with all_equal distribution", "[probe]",
3333
// Ensure that all measures of presortedness return 0 when
3434
// given a collection where all elements are equal
3535

36-
std::vector<int> collection(50, 5);
36+
const std::vector<int> collection(50, 5);
3737
std::decay_t<TestType> mop;
3838
auto presortedness = mop(collection);
3939
CHECK( presortedness == 0 );
@@ -88,14 +88,14 @@ TEMPLATE_TEST_CASE( "test every probe with a 0 or 1 element", "[probe]",
8888

8989
SECTION( "empty collection" )
9090
{
91-
std::vector<int> collection;
91+
const std::vector<int> collection;
9292
auto presortedness = mop(collection);
9393
CHECK( presortedness == 0 );
9494
}
9595

9696
SECTION( "one-element collection" )
9797
{
98-
std::vector<int> collection = { 42 };
98+
const std::vector<int> collection = { 42 };
9999
auto presortedness = mop(collection);
100100
CHECK( presortedness == 0 );
101101
}

tests/probes/exc.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ TEST_CASE( "presortedness measure: exc", "[probe][exc]" )
1717

1818
SECTION( "simple test" )
1919
{
20-
std::forward_list<int> li = { 74, 59, 62, 23, 86, 69, 18, 52, 77, 68 };
20+
const std::forward_list<int> li = { 74, 59, 62, 23, 86, 69, 18, 52, 77, 68 };
2121
CHECK( exc(li) == 7 );
2222
CHECK( exc(li.begin(), li.end()) == 7 );
2323

24-
std::forward_list<int> li2 = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
24+
const std::forward_list<int> li2 = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
2525
CHECK( exc(li2) == 5 );
2626
CHECK( exc(li2.begin(), li2.end()) == 5 );
2727

28-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
28+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
2929
CHECK( exc(tricky, &internal_compare<int>::compare_to) == 7 );
3030
}
3131

@@ -34,7 +34,7 @@ TEST_CASE( "presortedness measure: exc", "[probe][exc]" )
3434
// The upper bound should correspond to the size of
3535
// the input sequence minus one
3636

37-
std::forward_list<int> li = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
37+
const std::forward_list<int> li = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
3838
auto max_n = exc.max_for_size(cppsort::utility::size(li));
3939
CHECK( max_n == 10 );
4040
CHECK( exc(li) == max_n );
@@ -53,7 +53,7 @@ TEST_CASE( "presortedness measure: exc", "[probe][exc]" )
5353

5454
SECTION( "regression: first and last elements of a cycle compare equal" )
5555
{
56-
std::vector<int> collection = { 0, 0, -1 };
56+
const std::vector<int> collection = { 0, 0, -1 };
5757
CHECK( exc(collection) == 1 );
5858
}
5959
}

tests/probes/ham.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TEST_CASE( "presortedness measure: ham", "[probe][ham]" )
1919

2020
SECTION( "simple test" )
2121
{
22-
std::forward_list<int> li = { 34, 43, 96, 42, 44, 48, 57, 42, 68, 69 };
22+
const std::forward_list<int> li = { 34, 43, 96, 42, 44, 48, 57, 42, 68, 69 };
2323
CHECK( ham(li) == 6 );
2424
CHECK( ham(li.begin(), li.end()) == 6 );
2525

@@ -32,7 +32,7 @@ TEST_CASE( "presortedness measure: ham", "[probe][ham]" )
3232
// The upper bound should correspond to the size of
3333
// the input sequence
3434

35-
std::forward_list<int> li = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
35+
const std::forward_list<int> li = { 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
3636
auto max_n = ham.max_for_size(cppsort::utility::size(li));
3737
CHECK( max_n == 11 );
3838
CHECK( ham(li) == max_n );

tests/probes/max.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -17,11 +17,11 @@ TEST_CASE( "presortedness measure: max", "[probe][max]" )
1717

1818
SECTION( "simple test" )
1919
{
20-
std::forward_list<int> li = { 12, 28, 17, 59, 13, 10, 39, 21, 31, 30 };
20+
const std::forward_list<int> li = { 12, 28, 17, 59, 13, 10, 39, 21, 31, 30 };
2121
CHECK( (max)(li) == 6 );
2222
CHECK( (max)(li.begin(), li.end()) == 6 );
2323

24-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
24+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
2525
CHECK( (max)(tricky, &internal_compare<int>::compare_to) == 6 );
2626
}
2727

@@ -30,7 +30,7 @@ TEST_CASE( "presortedness measure: max", "[probe][max]" )
3030
// The upper bound should correspond to the size of
3131
// the input sequence minus one
3232

33-
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
33+
const std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
3434
auto max_n = (max).max_for_size(cppsort::utility::size(li));
3535
CHECK( max_n == 10 );
3636
CHECK( (max)(li) == max_n );

tests/probes/osc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -19,7 +19,7 @@ TEST_CASE( "presortedness measure: osc", "[probe][osc]" )
1919
// Example from the paper Adaptive Heapsort
2020
// by Levcopoulos and Petersson
2121

22-
std::forward_list<int> li = { 6, 3, 9, 8, 4, 7, 1, 11 };
22+
const std::forward_list<int> li = { 6, 3, 9, 8, 4, 7, 1, 11 };
2323
CHECK( osc(li) == 17 );
2424
CHECK( osc(li.begin(), li.end()) == 17 );
2525

@@ -33,7 +33,7 @@ TEST_CASE( "presortedness measure: osc", "[probe][osc]" )
3333
// by Levcopoulos and Petersson, the upper bound
3434
// should be (size * (size - 2) - 1) / 2
3535

36-
std::forward_list<int> li = { 8, 5, 10, 3, 12, 1, 13, 2, 11, 4, 9, 6, 7 };
36+
const std::forward_list<int> li = { 8, 5, 10, 3, 12, 1, 13, 2, 11, 4, 9, 6, 7 };
3737
auto max_n = osc.max_for_size(cppsort::utility::size(li));
3838
CHECK( max_n == 71 );
3939
CHECK( osc(li) == max_n );
@@ -43,7 +43,7 @@ TEST_CASE( "presortedness measure: osc", "[probe][osc]" )
4343
SECTION( "regressions" )
4444
{
4545
using wrapper = generic_wrapper<generic_wrapper<int>>;
46-
std::vector<wrapper> vec = { {{6}}, {{3}}, {{9}}, {{8}}, {{4}}, {{7}}, {{1}}, {{11}} };
46+
const std::vector<wrapper> vec = { {{6}}, {{3}}, {{9}}, {{8}}, {{4}}, {{7}}, {{1}}, {{11}} };
4747
auto comp = [](generic_wrapper<int> const& lhs, generic_wrapper<int> const& rhs) {
4848
return lhs.value < rhs.value;
4949
};

tests/probes/rem.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -16,16 +16,16 @@ TEST_CASE( "presortedness measure: rem", "[probe][rem]" )
1616
SECTION( "simple test" )
1717
{
1818
// Forward iterators
19-
std::forward_list<int> li = { 6, 9, 79, 41, 44, 49, 11, 16, 69, 15 };
19+
const std::forward_list<int> li = { 6, 9, 79, 41, 44, 49, 11, 16, 69, 15 };
2020
CHECK( rem(li) == 4 );
2121
CHECK( rem(li.begin(), li.end()) == 4 );
2222

2323
// Random-access iterators
24-
std::vector<int> vec(li.begin(), li.end());
24+
const std::vector<int> vec(li.begin(), li.end());
2525
CHECK( rem(vec) == 4 );
2626
CHECK( rem(vec.begin(), vec.end()) == 4 );
2727

28-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
28+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
2929
CHECK( rem(tricky, &internal_compare<int>::compare_to) == 4 );
3030
}
3131

@@ -34,7 +34,7 @@ TEST_CASE( "presortedness measure: rem", "[probe][rem]" )
3434
// The upper bound should correspond to the size of
3535
// the input sequence minus one
3636

37-
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
37+
const std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
3838
auto max_n = rem.max_for_size(cppsort::utility::size(li));
3939
CHECK( max_n == 10 );
4040
CHECK( rem(li) == max_n );

tests/probes/runs.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2022 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <forward_list>
@@ -15,17 +15,17 @@ TEST_CASE( "presortedness measure: runs", "[probe][runs]" )
1515

1616
SECTION( "simple tests" )
1717
{
18-
std::forward_list<int> li = { 40, 49, 58, 99, 60, 70, 12, 87, 9, 8, 82, 91, 99, 67, 82, 92 };
18+
const std::forward_list<int> li = { 40, 49, 58, 99, 60, 70, 12, 87, 9, 8, 82, 91, 99, 67, 82, 92 };
1919
CHECK( runs(li) == 5 );
2020
CHECK( runs(li.begin(), li.end()) == 5 );
2121

2222
// From Right invariant metrics and measures of
2323
// presortedness by Estivill-Castro, Mannila and Wood
24-
std::forward_list<int> li2 = { 4, 2, 6, 5, 3, 1, 9, 7, 10, 8 };
24+
const std::forward_list<int> li2 = { 4, 2, 6, 5, 3, 1, 9, 7, 10, 8 };
2525
CHECK( runs(li2) == 6 );
2626
CHECK( runs(li2.begin(), li2.end()) == 6 );
2727

28-
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
28+
const std::vector<internal_compare<int>> tricky(li.begin(), li.end());
2929
CHECK( runs(tricky, &internal_compare<int>::compare_to) == 5 );
3030
}
3131

@@ -34,7 +34,7 @@ TEST_CASE( "presortedness measure: runs", "[probe][runs]" )
3434
// The upper bound should correspond to the size of
3535
// the input sequence minus one
3636

37-
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
37+
const std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
3838
auto max_n = runs.max_for_size(cppsort::utility::size(li));
3939
CHECK( max_n == 10 );
4040
CHECK( runs(li) == max_n );

0 commit comments

Comments
 (0)