Skip to content

Commit ae0db04

Browse files
committed
Move count tests to their own file.
1 parent 97b3339 commit ae0db04

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

source/containers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ target_sources(containers_test PRIVATE
225225
test/sort/test_sort.cpp
226226
test/algorithms/adjacent.cpp
227227
test/algorithms/chunk_by.cpp
228+
test/algorithms/count.cpp
228229
test/algorithms/concatenate_view.cpp
229230
test/algorithms/copy_or_relocate_from.cpp
230231
test/algorithms/erase.cpp

source/containers/algorithms/count.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ module;
99

1010
export module containers.algorithms.count;
1111

12-
import containers.array;
1312
import containers.begin_end;
1413
import containers.count_type;
1514
import containers.range;
16-
import containers.size;
1715

1816
import bounded;
19-
import std_module;
2017

2118
using namespace bounded::literal;
2219

@@ -38,15 +35,3 @@ export constexpr auto count(range auto && range, auto const & value) {
3835
}
3936

4037
} // namespace containers
41-
42-
constexpr auto array = containers::array({0, 3, 2, 3, 5});
43-
44-
static_assert(containers::count(array, 3) == 2_bi);
45-
static_assert(containers::count(array, 2) == 1_bi);
46-
static_assert(containers::count(array, 7) == 0_bi);
47-
48-
constexpr auto false_function = [](auto const &) { return false; };
49-
constexpr auto true_function = [](auto const &) { return true; };
50-
51-
static_assert(containers::count_if(array, false_function) == 0_bi);
52-
static_assert(containers::count_if(array, true_function) == containers::size(array));
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright David Stone 2024.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
export module containers.test.algorithms.count;
7+
8+
import containers.algorithms.count;
9+
import containers.array;
10+
import containers.size;
11+
12+
import bounded;
13+
14+
using namespace bounded::literal;
15+
16+
constexpr auto array = containers::array({0, 3, 2, 3, 5});
17+
18+
static_assert(containers::count(array, 3) == 2_bi);
19+
static_assert(containers::count(array, 2) == 1_bi);
20+
static_assert(containers::count(array, 7) == 0_bi);
21+
22+
constexpr auto false_function = [](auto const &) { return false; };
23+
constexpr auto true_function = [](auto const &) { return true; };
24+
25+
static_assert(containers::count_if(array, false_function) == 0_bi);
26+
static_assert(containers::count_if(array, true_function) == containers::size(array));

0 commit comments

Comments
 (0)