9 #include <boost/test/unit_test.hpp>
20 using namespace detail;
28 BOOST_CHECK_EQUAL(a.getNBins(), 10
u);
29 BOOST_CHECK_EQUAL(a.getMax(), 10.);
30 BOOST_CHECK_EQUAL(a.getMin(), 0.);
31 BOOST_CHECK_EQUAL(a.getBinWidth(), 1.);
34 BOOST_CHECK_EQUAL(a.getBin(-0.3), 0
u);
35 BOOST_CHECK_EQUAL(a.getBin(-0.), 1
u);
36 BOOST_CHECK_EQUAL(a.getBin(0.), 1
u);
37 BOOST_CHECK_EQUAL(a.getBin(0.7), 1
u);
38 BOOST_CHECK_EQUAL(a.getBin(1), 2
u);
39 BOOST_CHECK_EQUAL(a.getBin(1.2), 2
u);
40 BOOST_CHECK_EQUAL(a.getBin(2.), 3
u);
41 BOOST_CHECK_EQUAL(a.getBin(2.7), 3
u);
42 BOOST_CHECK_EQUAL(a.getBin(3.), 4
u);
43 BOOST_CHECK_EQUAL(a.getBin(3.6), 4
u);
44 BOOST_CHECK_EQUAL(a.getBin(4.), 5
u);
45 BOOST_CHECK_EQUAL(a.getBin(4.98), 5
u);
46 BOOST_CHECK_EQUAL(a.getBin(5.), 6
u);
47 BOOST_CHECK_EQUAL(a.getBin(5.12), 6
u);
48 BOOST_CHECK_EQUAL(a.getBin(6.), 7
u);
49 BOOST_CHECK_EQUAL(a.getBin(6.00001), 7
u);
50 BOOST_CHECK_EQUAL(a.getBin(7.), 8
u);
51 BOOST_CHECK_EQUAL(a.getBin(7.5), 8
u);
52 BOOST_CHECK_EQUAL(a.getBin(8.), 9
u);
53 BOOST_CHECK_EQUAL(a.getBin(8.1), 9
u);
54 BOOST_CHECK_EQUAL(a.getBin(9.), 10
u);
55 BOOST_CHECK_EQUAL(a.getBin(9.999), 10
u);
56 BOOST_CHECK_EQUAL(a.getBin(10.), 11
u);
57 BOOST_CHECK_EQUAL(a.getBin(100.3), 11
u);
60 BOOST_CHECK_EQUAL(a.getBinLowerBound(1), 0.);
61 BOOST_CHECK_EQUAL(a.getBinLowerBound(2), 1.);
62 BOOST_CHECK_EQUAL(a.getBinLowerBound(3), 2.);
63 BOOST_CHECK_EQUAL(a.getBinLowerBound(4), 3.);
64 BOOST_CHECK_EQUAL(a.getBinLowerBound(5), 4.);
65 BOOST_CHECK_EQUAL(a.getBinLowerBound(6), 5.);
66 BOOST_CHECK_EQUAL(a.getBinLowerBound(7), 6.);
67 BOOST_CHECK_EQUAL(a.getBinLowerBound(8), 7.);
68 BOOST_CHECK_EQUAL(a.getBinLowerBound(9), 8.);
69 BOOST_CHECK_EQUAL(a.getBinLowerBound(10), 9.);
72 BOOST_CHECK_EQUAL(a.getBinUpperBound(1), 1.);
73 BOOST_CHECK_EQUAL(a.getBinUpperBound(2), 2.);
74 BOOST_CHECK_EQUAL(a.getBinUpperBound(3), 3.);
75 BOOST_CHECK_EQUAL(a.getBinUpperBound(4), 4.);
76 BOOST_CHECK_EQUAL(a.getBinUpperBound(5), 5.);
77 BOOST_CHECK_EQUAL(a.getBinUpperBound(6), 6.);
78 BOOST_CHECK_EQUAL(a.getBinUpperBound(7), 7.);
79 BOOST_CHECK_EQUAL(a.getBinUpperBound(8), 8.);
80 BOOST_CHECK_EQUAL(a.getBinUpperBound(9), 9.);
81 BOOST_CHECK_EQUAL(a.getBinUpperBound(10), 10.);
84 BOOST_CHECK_EQUAL(a.getBinCenter(1), 0.5);
85 BOOST_CHECK_EQUAL(a.getBinCenter(2), 1.5);
86 BOOST_CHECK_EQUAL(a.getBinCenter(3), 2.5);
87 BOOST_CHECK_EQUAL(a.getBinCenter(4), 3.5);
88 BOOST_CHECK_EQUAL(a.getBinCenter(5), 4.5);
89 BOOST_CHECK_EQUAL(a.getBinCenter(6), 5.5);
90 BOOST_CHECK_EQUAL(a.getBinCenter(7), 6.5);
91 BOOST_CHECK_EQUAL(a.getBinCenter(8), 7.5);
92 BOOST_CHECK_EQUAL(a.getBinCenter(9), 8.5);
93 BOOST_CHECK_EQUAL(a.getBinCenter(10), 9.5);
96 BOOST_CHECK(not a.isInside(-0.2));
97 BOOST_CHECK(a.isInside(0.));
98 BOOST_CHECK(a.isInside(3.));
99 BOOST_CHECK(not a.isInside(10.));
100 BOOST_CHECK(not a.isInside(12.));
107 BOOST_CHECK_EQUAL(
a.getNBins(), 4
u);
108 BOOST_CHECK_EQUAL(
a.getMax(), 6.);
109 BOOST_CHECK_EQUAL(
a.getMin(), 0.);
112 BOOST_CHECK_EQUAL(
a.getBin(-0.3), 0
u);
113 BOOST_CHECK_EQUAL(
a.getBin(-0.), 1
u);
114 BOOST_CHECK_EQUAL(
a.getBin(0.), 1
u);
115 BOOST_CHECK_EQUAL(
a.getBin(0.3), 1
u);
116 BOOST_CHECK_EQUAL(
a.getBin(0.5), 2
u);
117 BOOST_CHECK_EQUAL(
a.getBin(1.2), 2
u);
118 BOOST_CHECK_EQUAL(
a.getBin(2.7), 2
u);
119 BOOST_CHECK_EQUAL(
a.getBin(3.), 3
u);
120 BOOST_CHECK_EQUAL(
a.getBin(4.49999), 3
u);
121 BOOST_CHECK_EQUAL(
a.getBin(4.5), 4
u);
122 BOOST_CHECK_EQUAL(
a.getBin(5.12), 4
u);
123 BOOST_CHECK_EQUAL(
a.getBin(6.), 5
u);
124 BOOST_CHECK_EQUAL(
a.getBin(6.00001), 5
u);
125 BOOST_CHECK_EQUAL(
a.getBin(7.5), 5
u);
128 BOOST_CHECK_EQUAL(
a.getBinLowerBound(1), 0.);
129 BOOST_CHECK_EQUAL(
a.getBinLowerBound(2), 0.5);
130 BOOST_CHECK_EQUAL(
a.getBinLowerBound(3), 3.);
131 BOOST_CHECK_EQUAL(
a.getBinLowerBound(4), 4.5);
134 BOOST_CHECK_EQUAL(
a.getBinUpperBound(1), 0.5);
135 BOOST_CHECK_EQUAL(
a.getBinUpperBound(2), 3.);
136 BOOST_CHECK_EQUAL(
a.getBinUpperBound(3), 4.5);
137 BOOST_CHECK_EQUAL(
a.getBinUpperBound(4), 6.);
140 BOOST_CHECK_EQUAL(
a.getBinCenter(1), 0.25);
141 BOOST_CHECK_EQUAL(
a.getBinCenter(2), 1.75);
142 BOOST_CHECK_EQUAL(
a.getBinCenter(3), 3.75);
143 BOOST_CHECK_EQUAL(
a.getBinCenter(4), 5.25);
146 BOOST_CHECK(not
a.isInside(-0.2));
147 BOOST_CHECK(
a.isInside(0.));
148 BOOST_CHECK(
a.isInside(3.));
149 BOOST_CHECK(not
a.isInside(6.));
150 BOOST_CHECK(not
a.isInside(12.));
157 BOOST_CHECK_EQUAL(a.getBin(0.5), 1
u);
158 BOOST_CHECK_EQUAL(a.getBin(9.5), 10
u);
162 BOOST_CHECK_EQUAL(a.getBin(-0.5), 1
u);
163 BOOST_CHECK_EQUAL(a.getBin(10.5), 10
u);
166 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
169 BOOST_CHECK_EQUAL(
b.getBin(0.5), 1
u);
170 BOOST_CHECK_EQUAL(
b.getBin(9.5), 10
u);
174 BOOST_CHECK_EQUAL(
b.getBin(-0.5), 1
u);
175 BOOST_CHECK_EQUAL(
b.getBin(10.5), 10
u);
182 BOOST_CHECK_EQUAL(a.getBin(0.5), 1
u);
183 BOOST_CHECK_EQUAL(a.getBin(9.5), 10
u);
187 BOOST_CHECK_EQUAL(a.getBin(-0.5), 10
u);
188 BOOST_CHECK_EQUAL(a.getBin(10.5), 1
u);
191 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
194 BOOST_CHECK_EQUAL(
b.getBin(0.5), 1
u);
195 BOOST_CHECK_EQUAL(
b.getBin(9.5), 10
u);
199 BOOST_CHECK_EQUAL(
b.getBin(-0.5), 10
u);
200 BOOST_CHECK_EQUAL(
b.getBin(10.5), 1
u);
204 using bins_t = std::vector<size_t>;
207 BOOST_CHECK(a1.neighborHoodIndices(0, 1).collect() == bins_t({0, 1}));
208 BOOST_CHECK(a1.neighborHoodIndices(1, 1).collect() == bins_t({0, 1, 2}));
209 BOOST_CHECK(a1.neighborHoodIndices(11, 1).collect() == bins_t({10, 11}));
210 BOOST_CHECK(a1.neighborHoodIndices(10, 1).collect() == bins_t({9, 10, 11}));
211 BOOST_CHECK(a1.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
212 BOOST_CHECK(a1.neighborHoodIndices(5, {-1, 0}).collect() == bins_t({4, 5}));
213 BOOST_CHECK(a1.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
215 BOOST_CHECK(a1.neighborHoodIndices(0, 2).collect() == bins_t({0, 1, 2}));
216 BOOST_CHECK(a1.neighborHoodIndices(1, 2).collect() == bins_t({0, 1, 2, 3}));
217 BOOST_CHECK(a1.neighborHoodIndices(11, 2).collect() == bins_t({9, 10, 11}));
218 BOOST_CHECK(a1.neighborHoodIndices(10, 2).collect() ==
219 bins_t({8, 9, 10, 11}));
220 BOOST_CHECK(a1.neighborHoodIndices(5, 2).collect() ==
221 bins_t({3, 4, 5, 6, 7}));
224 {0.0, 2.0, 4.0, 9.0, 10.0});
225 BOOST_CHECK(
a2.neighborHoodIndices(0, 1).collect() == bins_t({0, 1}));
226 BOOST_CHECK(
a2.neighborHoodIndices(1, 1).collect() == bins_t({0, 1, 2}));
227 BOOST_CHECK(
a2.neighborHoodIndices(5, 1).collect() == bins_t({4, 5}));
228 BOOST_CHECK(
a2.neighborHoodIndices(4, 1).collect() == bins_t({3, 4, 5}));
229 BOOST_CHECK(
a2.neighborHoodIndices(4, {-1, 0}).collect() == bins_t({3, 4}));
230 BOOST_CHECK(
a2.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
231 BOOST_CHECK(
a2.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
233 BOOST_CHECK(
a2.neighborHoodIndices(0, 2).collect() == bins_t({0, 1, 2}));
234 BOOST_CHECK(
a2.neighborHoodIndices(1, 2).collect() == bins_t({0, 1, 2, 3}));
235 BOOST_CHECK(
a2.neighborHoodIndices(5, 2).collect() == bins_t({3, 4, 5}));
236 BOOST_CHECK(
a2.neighborHoodIndices(4, 2).collect() == bins_t({2, 3, 4, 5}));
237 BOOST_CHECK(
a2.neighborHoodIndices(3, 2).collect() ==
238 bins_t({1, 2, 3, 4, 5}));
242 BOOST_CHECK(a3.neighborHoodIndices(0, 1).collect() == bins_t({}));
243 BOOST_CHECK(a3.neighborHoodIndices(1, 1).collect() == bins_t({1, 2}));
244 BOOST_CHECK(a3.neighborHoodIndices(11, 1).collect() == bins_t({}));
245 BOOST_CHECK(a3.neighborHoodIndices(10, 1).collect() == bins_t({9, 10}));
246 BOOST_CHECK(a3.neighborHoodIndices(10, {0, 1}).collect() == bins_t({10}));
247 BOOST_CHECK(a3.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
248 BOOST_CHECK(a3.neighborHoodIndices(5, {-1, 0}).collect() == bins_t({4, 5}));
249 BOOST_CHECK(a3.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
251 BOOST_CHECK(a3.neighborHoodIndices(0, 2).collect() == bins_t({}));
252 BOOST_CHECK(a3.neighborHoodIndices(1, 2).collect() == bins_t({1, 2, 3}));
253 BOOST_CHECK(a3.neighborHoodIndices(11, 2).collect() == bins_t({}));
254 BOOST_CHECK(a3.neighborHoodIndices(10, 2).collect() == bins_t({8, 9, 10}));
255 BOOST_CHECK(a3.neighborHoodIndices(5, 2).collect() ==
256 bins_t({3, 4, 5, 6, 7}));
260 BOOST_CHECK(a4.neighborHoodIndices(0, 1).collect() == bins_t({}));
261 BOOST_CHECK(a4.neighborHoodIndices(1, 1).collect() == bins_t({10, 1, 2}));
262 BOOST_CHECK(a4.neighborHoodIndices(11, 1).collect() == bins_t({}));
263 BOOST_CHECK(a4.neighborHoodIndices(10, 1).collect() == bins_t({9, 10, 1}));
264 BOOST_CHECK(a4.neighborHoodIndices(10, {0, 1}).collect() == bins_t({10, 1}));
265 BOOST_CHECK(a4.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
266 BOOST_CHECK(a4.neighborHoodIndices(5, {-1, 0}).collect() == bins_t({4, 5}));
267 BOOST_CHECK(a4.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
269 BOOST_CHECK(a4.neighborHoodIndices(0, 2).collect() == bins_t({}));
270 BOOST_CHECK(a4.neighborHoodIndices(1, 2).collect() ==
271 bins_t({9, 10, 1, 2, 3}));
272 BOOST_CHECK(a4.neighborHoodIndices(11, 2).collect() == bins_t({}));
273 BOOST_CHECK(a4.neighborHoodIndices(10, 2).collect() ==
274 bins_t({8, 9, 10, 1, 2}));
275 BOOST_CHECK(a4.neighborHoodIndices(5, 2).collect() ==
276 bins_t({3, 4, 5, 6, 7}));
279 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
280 BOOST_CHECK(a5.neighborHoodIndices(0, 1).collect() == bins_t({}));
281 BOOST_CHECK(a5.neighborHoodIndices(1, 1).collect() == bins_t({1, 2}));
282 BOOST_CHECK(a5.neighborHoodIndices(6, 1).collect() == bins_t({}));
283 BOOST_CHECK(a5.neighborHoodIndices(5, 1).collect() == bins_t({4, 5}));
284 BOOST_CHECK(a5.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5}));
285 BOOST_CHECK(a5.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
286 BOOST_CHECK(a5.neighborHoodIndices(2, {-1, 0}).collect() == bins_t({1, 2}));
287 BOOST_CHECK(a5.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
289 BOOST_CHECK(a5.neighborHoodIndices(0, 2).collect() == bins_t({}));
290 BOOST_CHECK(a5.neighborHoodIndices(1, 2).collect() == bins_t({1, 2, 3}));
291 BOOST_CHECK(a5.neighborHoodIndices(6, 2).collect() == bins_t({}));
292 BOOST_CHECK(a5.neighborHoodIndices(5, 2).collect() == bins_t({3, 4, 5}));
293 BOOST_CHECK(a5.neighborHoodIndices(3, 2).collect() ==
294 bins_t({1, 2, 3, 4, 5}));
297 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
298 BOOST_CHECK(a6.neighborHoodIndices(0, 1).collect() == bins_t({}));
299 BOOST_CHECK(a6.neighborHoodIndices(1, 1).collect() == bins_t({5, 1, 2}));
300 BOOST_CHECK(a6.neighborHoodIndices(6, 1).collect() == bins_t({}));
301 BOOST_CHECK(a6.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 1}));
302 BOOST_CHECK(a6.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 1}));
303 BOOST_CHECK(a6.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
304 BOOST_CHECK(a6.neighborHoodIndices(2, {-1, 0}).collect() == bins_t({1, 2}));
305 BOOST_CHECK(a6.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
307 BOOST_CHECK(a6.neighborHoodIndices(0, 2).collect() == bins_t({}));
308 BOOST_CHECK(a6.neighborHoodIndices(1, 2).collect() ==
309 bins_t({4, 5, 1, 2, 3}));
310 BOOST_CHECK(a6.neighborHoodIndices(6, 2).collect() == bins_t({}));
311 BOOST_CHECK(a6.neighborHoodIndices(5, 2).collect() ==
312 bins_t({3, 4, 5, 1, 2}));
313 BOOST_CHECK(a6.neighborHoodIndices(3, 2).collect() ==
314 bins_t({1, 2, 3, 4, 5}));
315 BOOST_CHECK(a6.neighborHoodIndices(3, {0, 2}).collect() == bins_t({3, 4, 5}));
317 BOOST_CHECK(a6.neighborHoodIndices(1, 3).collect() ==
318 bins_t({1, 2, 3, 4, 5}));
319 BOOST_CHECK(a6.neighborHoodIndices(5, 3).collect() ==
320 bins_t({1, 2, 3, 4, 5}));
325 BOOST_CHECK_EQUAL(a1.wrapBin(0), 0
u);
326 BOOST_CHECK_EQUAL(a1.wrapBin(1), 1
u);
327 BOOST_CHECK_EQUAL(a1.wrapBin(-1), 0
u);
328 BOOST_CHECK_EQUAL(a1.wrapBin(10), 10
u);
329 BOOST_CHECK_EQUAL(a1.wrapBin(11), 11
u);
330 BOOST_CHECK_EQUAL(a1.wrapBin(12), 11
u);
333 BOOST_CHECK_EQUAL(a2.wrapBin(0), 1
u);
334 BOOST_CHECK_EQUAL(a2.wrapBin(1), 1
u);
335 BOOST_CHECK_EQUAL(a2.wrapBin(-1), 1
u);
336 BOOST_CHECK_EQUAL(a2.wrapBin(10), 10
u);
337 BOOST_CHECK_EQUAL(a2.wrapBin(11), 10
u);
338 BOOST_CHECK_EQUAL(a2.wrapBin(12), 10
u);
341 BOOST_CHECK_EQUAL(a3.wrapBin(0), 10
u);
342 BOOST_CHECK_EQUAL(a3.wrapBin(1), 1
u);
343 BOOST_CHECK_EQUAL(a3.wrapBin(-1), 9
u);
344 BOOST_CHECK_EQUAL(a3.wrapBin(10), 10
u);
345 BOOST_CHECK_EQUAL(a3.wrapBin(11), 1
u);
346 BOOST_CHECK_EQUAL(a3.wrapBin(12), 2
u);
349 {0.0, 2.0, 4.0, 9.0, 10.0});
350 BOOST_CHECK_EQUAL(a4.wrapBin(0), 0
u);
351 BOOST_CHECK_EQUAL(a4.wrapBin(1), 1
u);
352 BOOST_CHECK_EQUAL(a4.wrapBin(-1), 0
u);
353 BOOST_CHECK_EQUAL(a4.wrapBin(4), 4
u);
354 BOOST_CHECK_EQUAL(a4.wrapBin(5), 5
u);
355 BOOST_CHECK_EQUAL(a4.wrapBin(6), 5
u);
358 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
359 BOOST_CHECK_EQUAL(a5.wrapBin(0), 1
u);
360 BOOST_CHECK_EQUAL(a5.wrapBin(1), 1
u);
361 BOOST_CHECK_EQUAL(a5.wrapBin(-1), 1
u);
362 BOOST_CHECK_EQUAL(a5.wrapBin(4), 4
u);
363 BOOST_CHECK_EQUAL(a5.wrapBin(5), 5
u);
364 BOOST_CHECK_EQUAL(a5.wrapBin(6), 5
u);
367 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
368 BOOST_CHECK_EQUAL(a6.wrapBin(0), 5
u);
369 BOOST_CHECK_EQUAL(a6.wrapBin(1), 1
u);
370 BOOST_CHECK_EQUAL(a6.wrapBin(-1), 4
u);
371 BOOST_CHECK_EQUAL(a6.wrapBin(4), 4
u);
372 BOOST_CHECK_EQUAL(a6.wrapBin(5), 5
u);
373 BOOST_CHECK_EQUAL(a6.wrapBin(6), 1
u);
374 BOOST_CHECK_EQUAL(a6.wrapBin(7), 2
u);