11 #define BOOST_TEST_MODULE FixedBins
12 #include <boost/test/unit_test.hpp>
22 std::vector<unsigned int> expectedContent;
24 BOOST_TEST((bins.binWidth() == 2.0));
25 BOOST_TEST((bins.offset() == -1.0));
27 BOOST_CHECK((bins.empty()));
28 BOOST_CHECK((
empty(bins)));
29 BOOST_TEST((bins.size() == 0U));
30 BOOST_TEST((
size(bins) == 0U));
31 BOOST_TEST((bins.cbegin() == bins.cend()));
32 BOOST_TEST((bins.begin() == bins.end()));
33 BOOST_TEST((bins.nBins() == 0U));
34 BOOST_TEST((bins.range() == 0.0));
35 BOOST_TEST((bins.count(-2) == 0U));
36 BOOST_TEST((bins.count(-1) == 0U));
37 BOOST_TEST((bins.count( 0) == 0U));
38 BOOST_TEST((bins.count( 1) == 0U));
39 BOOST_TEST((bins.count( 2) == 0U));
40 BOOST_TEST((bins.countFor(-5.0) == 0U));
41 BOOST_TEST((bins.countFor(-4.0) == 0U));
42 BOOST_TEST((bins.countFor(-3.0) == 0U));
43 BOOST_TEST((bins.countFor(-2.0) == 0U));
44 BOOST_TEST((bins.countFor(-1.0) == 0U));
45 BOOST_TEST((bins.countFor(-0.0) == 0U));
46 BOOST_TEST((bins.countFor(+0.0) == 0U));
47 BOOST_TEST((bins.countFor(+1.0) == 0U));
48 BOOST_TEST((bins.countFor(+2.0) == 0U));
49 BOOST_TEST((bins.countFor(+3.0) == 0U));
50 BOOST_TEST((bins.countFor(+4.0) == 0U));
51 BOOST_TEST((bins.countFor(+5.0) == 0U));
52 BOOST_TEST((bins[-2] == 0U));
53 BOOST_TEST((bins[-1] == 0U));
54 BOOST_TEST((bins[ 0] == 0U));
55 BOOST_TEST((bins[ 1] == 0U));
56 BOOST_TEST((bins[ 2] == 0U));
61 expectedContent = { 1 };
62 BOOST_CHECK((!bins.empty()));
63 BOOST_CHECK((!
empty(bins)));
64 BOOST_TEST((bins.size() == 1U));
65 BOOST_TEST((
size(bins) == 1U));
66 BOOST_CHECK_EQUAL_COLLECTIONS
67 (bins.begin(), bins.end(), expectedContent.begin(), expectedContent.end());
68 BOOST_CHECK_EQUAL_COLLECTIONS
69 (bins.cbegin(), bins.cend(), expectedContent.cbegin(), expectedContent.cend());
70 BOOST_CHECK_EQUAL_COLLECTIONS
71 (
begin(bins),
end(bins), expectedContent.begin(), expectedContent.end());
72 BOOST_CHECK_EQUAL_COLLECTIONS
73 (
cbegin(bins),
cend(bins), expectedContent.cbegin(), expectedContent.cend());
74 BOOST_TEST((bins.nBins() == 1U));
75 BOOST_TEST((bins.range() == 2.0));
76 BOOST_TEST((bins.minBin() == 0));
77 BOOST_TEST((bins.maxBin() == 0));
78 BOOST_TEST((bins.min() == +3.0));
79 BOOST_TEST((bins.max() == +5.0));
80 BOOST_TEST((bins.count(-2) == 0U));
81 BOOST_TEST((bins.count(-1) == 0U));
82 BOOST_TEST((bins.count( 0) == 1U));
83 BOOST_TEST((bins.count( 1) == 0U));
84 BOOST_TEST((bins.count( 2) == 0U));
85 BOOST_TEST((bins.countFor(-5.0) == 0U));
86 BOOST_TEST((bins.countFor(-4.0) == 0U));
87 BOOST_TEST((bins.countFor(-3.0) == 0U));
88 BOOST_TEST((bins.countFor(-2.0) == 0U));
89 BOOST_TEST((bins.countFor(-1.0) == 0U));
90 BOOST_TEST((bins.countFor(-0.0) == 0U));
91 BOOST_TEST((bins.countFor(+0.0) == 0U));
92 BOOST_TEST((bins.countFor(+1.0) == 0U));
93 BOOST_TEST((bins.countFor(+2.0) == 0U));
94 BOOST_TEST((bins.countFor(+3.0) == 1U));
95 BOOST_TEST((bins.countFor(+4.0) == 1U));
96 BOOST_TEST((bins.countFor(+5.0) == 0U));
97 BOOST_TEST((bins[-2] == 0U));
98 BOOST_TEST((bins[-1] == 0U));
99 BOOST_TEST((bins[ 0] == 1U));
100 BOOST_TEST((bins[ 1] == 0U));
101 BOOST_TEST((bins[ 2] == 0U));
106 expectedContent = { 1U, 0U, 0U, 0U, 1U };
107 BOOST_CHECK((!bins.empty()));
108 BOOST_CHECK((!
empty(bins)));
109 BOOST_TEST((bins.size() == 5U));
110 BOOST_TEST((
size(bins) == 5U));
111 BOOST_CHECK_EQUAL_COLLECTIONS
112 (bins.begin(), bins.end(), expectedContent.begin(), expectedContent.end());
113 BOOST_CHECK_EQUAL_COLLECTIONS
114 (bins.cbegin(), bins.cend(), expectedContent.cbegin(), expectedContent.cend());
115 BOOST_CHECK_EQUAL_COLLECTIONS
116 (
begin(bins),
end(bins), expectedContent.begin(), expectedContent.end());
117 BOOST_CHECK_EQUAL_COLLECTIONS
118 (
cbegin(bins),
cend(bins), expectedContent.cbegin(), expectedContent.cend());
119 BOOST_TEST((bins.nBins() == 5U));
120 BOOST_TEST((bins.range() == 10.0));
121 BOOST_TEST((bins.minBin() == -4));
122 BOOST_TEST((bins.maxBin() == 0));
123 BOOST_TEST((bins.min() == -5.0));
124 BOOST_TEST((bins.max() == +5.0));
125 BOOST_TEST((bins.count(-5) == 0U));
126 BOOST_TEST((bins.count(-4) == 1U));
127 BOOST_TEST((bins.count(-3) == 0U));
128 BOOST_TEST((bins.count(-2) == 0U));
129 BOOST_TEST((bins.count(-1) == 0U));
130 BOOST_TEST((bins.count( 0) == 1U));
131 BOOST_TEST((bins.count( 1) == 0U));
132 BOOST_TEST((bins.count( 2) == 0U));
133 BOOST_TEST((bins.countFor(-5.0) == 1U));
134 BOOST_TEST((bins.countFor(-4.0) == 1U));
135 BOOST_TEST((bins.countFor(-3.0) == 0U));
136 BOOST_TEST((bins.countFor(-2.0) == 0U));
137 BOOST_TEST((bins.countFor(-1.0) == 0U));
138 BOOST_TEST((bins.countFor(-0.0) == 0U));
139 BOOST_TEST((bins.countFor(+0.0) == 0U));
140 BOOST_TEST((bins.countFor(+1.0) == 0U));
141 BOOST_TEST((bins.countFor(+2.0) == 0U));
142 BOOST_TEST((bins.countFor(+3.0) == 1U));
143 BOOST_TEST((bins.countFor(+4.0) == 1U));
144 BOOST_TEST((bins.countFor(+5.0) == 0U));
145 BOOST_TEST((bins[-5] == 0U));
146 BOOST_TEST((bins[-4] == 1U));
147 BOOST_TEST((bins[-3] == 0U));
148 BOOST_TEST((bins[-2] == 0U));
149 BOOST_TEST((bins[-1] == 0U));
150 BOOST_TEST((bins[ 0] == 1U));
151 BOOST_TEST((bins[ 1] == 0U));
152 BOOST_TEST((bins[ 2] == 0U));
157 expectedContent = { 2U, 0U, 0U, 0U, 1U };
158 BOOST_CHECK((!bins.empty()));
159 BOOST_CHECK((!
empty(bins)));
160 BOOST_TEST((bins.size() == 5U));
161 BOOST_TEST((
size(bins) == 5U));
162 BOOST_CHECK_EQUAL_COLLECTIONS
163 (bins.begin(), bins.end(), expectedContent.begin(), expectedContent.end());
164 BOOST_CHECK_EQUAL_COLLECTIONS
165 (bins.cbegin(), bins.cend(), expectedContent.cbegin(), expectedContent.cend());
166 BOOST_CHECK_EQUAL_COLLECTIONS
167 (
begin(bins),
end(bins), expectedContent.begin(), expectedContent.end());
168 BOOST_CHECK_EQUAL_COLLECTIONS
169 (
cbegin(bins),
cend(bins), expectedContent.cbegin(), expectedContent.cend());
170 BOOST_TEST((bins.nBins() == 5U));
171 BOOST_TEST((bins.range() == 10.0));
172 BOOST_TEST((bins.minBin() == -4));
173 BOOST_TEST((bins.maxBin() == 0));
174 BOOST_TEST((bins.min() == -5.0));
175 BOOST_TEST((bins.max() == +5.0));
176 BOOST_TEST((bins.count(-5) == 0U));
177 BOOST_TEST((bins.count(-4) == 2U));
178 BOOST_TEST((bins.count(-3) == 0U));
179 BOOST_TEST((bins.count(-2) == 0U));
180 BOOST_TEST((bins.count(-1) == 0U));
181 BOOST_TEST((bins.count( 0) == 1U));
182 BOOST_TEST((bins.count( 1) == 0U));
183 BOOST_TEST((bins.count( 2) == 0U));
184 BOOST_TEST((bins.countFor(-5.0) == 2U));
185 BOOST_TEST((bins.countFor(-4.0) == 2U));
186 BOOST_TEST((bins.countFor(-3.0) == 0U));
187 BOOST_TEST((bins.countFor(-2.0) == 0U));
188 BOOST_TEST((bins.countFor(-1.0) == 0U));
189 BOOST_TEST((bins.countFor(-0.0) == 0U));
190 BOOST_TEST((bins.countFor(+0.0) == 0U));
191 BOOST_TEST((bins.countFor(+1.0) == 0U));
192 BOOST_TEST((bins.countFor(+2.0) == 0U));
193 BOOST_TEST((bins.countFor(+3.0) == 1U));
194 BOOST_TEST((bins.countFor(+4.0) == 1U));
195 BOOST_TEST((bins.countFor(+5.0) == 0U));
196 BOOST_TEST((bins[-5] == 0U));
197 BOOST_TEST((bins[-4] == 2U));
198 BOOST_TEST((bins[-3] == 0U));
199 BOOST_TEST((bins[-2] == 0U));
200 BOOST_TEST((bins[-1] == 0U));
201 BOOST_TEST((bins[ 0] == 1U));
202 BOOST_TEST((bins[ 1] == 0U));
203 BOOST_TEST((bins[ 2] == 0U));
208 BOOST_TEST((bins.binWidth() == 2.0));
209 BOOST_TEST((bins.offset() == -1.0));
211 BOOST_CHECK((bins.empty()));
212 BOOST_CHECK((
empty(bins)));
213 BOOST_TEST((bins.size() == 0U));
214 BOOST_TEST((
size(bins) == 0U));
215 BOOST_TEST((bins.cbegin() == bins.cend()));
216 BOOST_TEST((bins.begin() == bins.end()));
217 BOOST_TEST((bins.nBins() == 0U));
218 BOOST_TEST((bins.range() == 0.0));
219 BOOST_TEST((bins.count(-2) == 0U));
220 BOOST_TEST((bins.count(-1) == 0U));
221 BOOST_TEST((bins.count( 0) == 0U));
222 BOOST_TEST((bins.count( 1) == 0U));
223 BOOST_TEST((bins.count( 2) == 0U));
224 BOOST_TEST((bins.countFor(-5.0) == 0U));
225 BOOST_TEST((bins.countFor(-4.0) == 0U));
226 BOOST_TEST((bins.countFor(-3.0) == 0U));
227 BOOST_TEST((bins.countFor(-2.0) == 0U));
228 BOOST_TEST((bins.countFor(-1.0) == 0U));
229 BOOST_TEST((bins.countFor(-0.0) == 0U));
230 BOOST_TEST((bins.countFor(+0.0) == 0U));
231 BOOST_TEST((bins.countFor(+1.0) == 0U));
232 BOOST_TEST((bins.countFor(+2.0) == 0U));
233 BOOST_TEST((bins.countFor(+3.0) == 0U));
234 BOOST_TEST((bins.countFor(+4.0) == 0U));
235 BOOST_TEST((bins.countFor(+5.0) == 0U));
236 BOOST_TEST((bins[-2] == 0U));
237 BOOST_TEST((bins[-1] == 0U));
238 BOOST_TEST((bins[ 0] == 0U));
239 BOOST_TEST((bins[ 1] == 0U));
240 BOOST_TEST((bins[ 2] == 0U));
std::size_t size(FixedBins< T, C > const &) noexcept
auto cbegin(FixedBins< T, C > const &) noexcept
auto cend(FixedBins< T, C > const &) noexcept
auto end(FixedBins< T, C > const &) noexcept
Class with extensible fix-sized binning.
auto begin(FixedBins< T, C > const &) noexcept
bool empty(FixedBins< T, C > const &) noexcept