9 #include <boost/test/unit_test.hpp>
15 using namespace detail;
23 BOOST_CHECK_EQUAL(a.getNBins(), 10
u);
24 BOOST_CHECK_EQUAL(a.getMax(), 10.);
25 BOOST_CHECK_EQUAL(a.getMin(), 0.);
26 BOOST_CHECK_EQUAL(a.getBinWidth(), 1.);
29 BOOST_CHECK_EQUAL(a.getBin(-0.3), 0
u);
30 BOOST_CHECK_EQUAL(a.getBin(-0.), 1
u);
31 BOOST_CHECK_EQUAL(a.getBin(0.), 1
u);
32 BOOST_CHECK_EQUAL(a.getBin(0.7), 1
u);
33 BOOST_CHECK_EQUAL(a.getBin(1), 2
u);
34 BOOST_CHECK_EQUAL(a.getBin(1.2), 2
u);
35 BOOST_CHECK_EQUAL(a.getBin(2.), 3
u);
36 BOOST_CHECK_EQUAL(a.getBin(2.7), 3
u);
37 BOOST_CHECK_EQUAL(a.getBin(3.), 4
u);
38 BOOST_CHECK_EQUAL(a.getBin(3.6), 4
u);
39 BOOST_CHECK_EQUAL(a.getBin(4.), 5
u);
40 BOOST_CHECK_EQUAL(a.getBin(4.98), 5
u);
41 BOOST_CHECK_EQUAL(a.getBin(5.), 6
u);
42 BOOST_CHECK_EQUAL(a.getBin(5.12), 6
u);
43 BOOST_CHECK_EQUAL(a.getBin(6.), 7
u);
44 BOOST_CHECK_EQUAL(a.getBin(6.00001), 7
u);
45 BOOST_CHECK_EQUAL(a.getBin(7.), 8
u);
46 BOOST_CHECK_EQUAL(a.getBin(7.5), 8
u);
47 BOOST_CHECK_EQUAL(a.getBin(8.), 9
u);
48 BOOST_CHECK_EQUAL(a.getBin(8.1), 9
u);
49 BOOST_CHECK_EQUAL(a.getBin(9.), 10
u);
50 BOOST_CHECK_EQUAL(a.getBin(9.999), 10
u);
51 BOOST_CHECK_EQUAL(a.getBin(10.), 11
u);
52 BOOST_CHECK_EQUAL(a.getBin(100.3), 11
u);
55 BOOST_CHECK_EQUAL(a.getBinLowerBound(1), 0.);
56 BOOST_CHECK_EQUAL(a.getBinLowerBound(2), 1.);
57 BOOST_CHECK_EQUAL(a.getBinLowerBound(3), 2.);
58 BOOST_CHECK_EQUAL(a.getBinLowerBound(4), 3.);
59 BOOST_CHECK_EQUAL(a.getBinLowerBound(5), 4.);
60 BOOST_CHECK_EQUAL(a.getBinLowerBound(6), 5.);
61 BOOST_CHECK_EQUAL(a.getBinLowerBound(7), 6.);
62 BOOST_CHECK_EQUAL(a.getBinLowerBound(8), 7.);
63 BOOST_CHECK_EQUAL(a.getBinLowerBound(9), 8.);
64 BOOST_CHECK_EQUAL(a.getBinLowerBound(10), 9.);
67 BOOST_CHECK_EQUAL(a.getBinUpperBound(1), 1.);
68 BOOST_CHECK_EQUAL(a.getBinUpperBound(2), 2.);
69 BOOST_CHECK_EQUAL(a.getBinUpperBound(3), 3.);
70 BOOST_CHECK_EQUAL(a.getBinUpperBound(4), 4.);
71 BOOST_CHECK_EQUAL(a.getBinUpperBound(5), 5.);
72 BOOST_CHECK_EQUAL(a.getBinUpperBound(6), 6.);
73 BOOST_CHECK_EQUAL(a.getBinUpperBound(7), 7.);
74 BOOST_CHECK_EQUAL(a.getBinUpperBound(8), 8.);
75 BOOST_CHECK_EQUAL(a.getBinUpperBound(9), 9.);
76 BOOST_CHECK_EQUAL(a.getBinUpperBound(10), 10.);
79 BOOST_CHECK_EQUAL(a.getBinCenter(1), 0.5);
80 BOOST_CHECK_EQUAL(a.getBinCenter(2), 1.5);
81 BOOST_CHECK_EQUAL(a.getBinCenter(3), 2.5);
82 BOOST_CHECK_EQUAL(a.getBinCenter(4), 3.5);
83 BOOST_CHECK_EQUAL(a.getBinCenter(5), 4.5);
84 BOOST_CHECK_EQUAL(a.getBinCenter(6), 5.5);
85 BOOST_CHECK_EQUAL(a.getBinCenter(7), 6.5);
86 BOOST_CHECK_EQUAL(a.getBinCenter(8), 7.5);
87 BOOST_CHECK_EQUAL(a.getBinCenter(9), 8.5);
88 BOOST_CHECK_EQUAL(a.getBinCenter(10), 9.5);
91 BOOST_CHECK(not a.isInside(-0.2));
92 BOOST_CHECK(a.isInside(0.));
93 BOOST_CHECK(a.isInside(3.));
94 BOOST_CHECK(not a.isInside(10.));
95 BOOST_CHECK(not a.isInside(12.));
102 BOOST_CHECK_EQUAL(
a.getNBins(), 4
u);
103 BOOST_CHECK_EQUAL(
a.getMax(), 6.);
104 BOOST_CHECK_EQUAL(
a.getMin(), 0.);
107 BOOST_CHECK_EQUAL(
a.getBin(-0.3), 0
u);
108 BOOST_CHECK_EQUAL(
a.getBin(-0.), 1
u);
109 BOOST_CHECK_EQUAL(
a.getBin(0.), 1
u);
110 BOOST_CHECK_EQUAL(
a.getBin(0.3), 1
u);
111 BOOST_CHECK_EQUAL(
a.getBin(0.5), 2
u);
112 BOOST_CHECK_EQUAL(
a.getBin(1.2), 2
u);
113 BOOST_CHECK_EQUAL(
a.getBin(2.7), 2
u);
114 BOOST_CHECK_EQUAL(
a.getBin(3.), 3
u);
115 BOOST_CHECK_EQUAL(
a.getBin(4.49999), 3
u);
116 BOOST_CHECK_EQUAL(
a.getBin(4.5), 4
u);
117 BOOST_CHECK_EQUAL(
a.getBin(5.12), 4
u);
118 BOOST_CHECK_EQUAL(
a.getBin(6.), 5
u);
119 BOOST_CHECK_EQUAL(
a.getBin(6.00001), 5
u);
120 BOOST_CHECK_EQUAL(
a.getBin(7.5), 5
u);
123 BOOST_CHECK_EQUAL(
a.getBinLowerBound(1), 0.);
124 BOOST_CHECK_EQUAL(
a.getBinLowerBound(2), 0.5);
125 BOOST_CHECK_EQUAL(
a.getBinLowerBound(3), 3.);
126 BOOST_CHECK_EQUAL(
a.getBinLowerBound(4), 4.5);
129 BOOST_CHECK_EQUAL(
a.getBinUpperBound(1), 0.5);
130 BOOST_CHECK_EQUAL(
a.getBinUpperBound(2), 3.);
131 BOOST_CHECK_EQUAL(
a.getBinUpperBound(3), 4.5);
132 BOOST_CHECK_EQUAL(
a.getBinUpperBound(4), 6.);
135 BOOST_CHECK_EQUAL(
a.getBinCenter(1), 0.25);
136 BOOST_CHECK_EQUAL(
a.getBinCenter(2), 1.75);
137 BOOST_CHECK_EQUAL(
a.getBinCenter(3), 3.75);
138 BOOST_CHECK_EQUAL(
a.getBinCenter(4), 5.25);
141 BOOST_CHECK(not
a.isInside(-0.2));
142 BOOST_CHECK(
a.isInside(0.));
143 BOOST_CHECK(
a.isInside(3.));
144 BOOST_CHECK(not
a.isInside(6.));
145 BOOST_CHECK(not
a.isInside(12.));
152 BOOST_CHECK_EQUAL(a.getBin(0.5), 1
u);
153 BOOST_CHECK_EQUAL(a.getBin(9.5), 10
u);
157 BOOST_CHECK_EQUAL(a.getBin(-0.5), 1
u);
158 BOOST_CHECK_EQUAL(a.getBin(10.5), 10
u);
161 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
164 BOOST_CHECK_EQUAL(
b.getBin(0.5), 1
u);
165 BOOST_CHECK_EQUAL(
b.getBin(9.5), 10
u);
169 BOOST_CHECK_EQUAL(
b.getBin(-0.5), 1
u);
170 BOOST_CHECK_EQUAL(
b.getBin(10.5), 10
u);
177 BOOST_CHECK_EQUAL(a.getBin(0.5), 1
u);
178 BOOST_CHECK_EQUAL(a.getBin(9.5), 10
u);
182 BOOST_CHECK_EQUAL(a.getBin(-0.5), 10
u);
183 BOOST_CHECK_EQUAL(a.getBin(10.5), 1
u);
186 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
189 BOOST_CHECK_EQUAL(
b.getBin(0.5), 1
u);
190 BOOST_CHECK_EQUAL(
b.getBin(9.5), 10
u);
194 BOOST_CHECK_EQUAL(
b.getBin(-0.5), 10
u);
195 BOOST_CHECK_EQUAL(
b.getBin(10.5), 1
u);
199 using bins_t = std::vector<size_t>;
202 BOOST_CHECK(a1.neighborHoodIndices(0, 1).collect() == bins_t({0, 1}));
203 BOOST_CHECK(a1.neighborHoodIndices(1, 1).collect() == bins_t({0, 1, 2}));
204 BOOST_CHECK(a1.neighborHoodIndices(11, 1).collect() == bins_t({10, 11}));
205 BOOST_CHECK(a1.neighborHoodIndices(10, 1).collect() == bins_t({9, 10, 11}));
206 BOOST_CHECK(a1.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
207 BOOST_CHECK(a1.neighborHoodIndices(5, {1, 0}).collect() == bins_t({4, 5}));
208 BOOST_CHECK(a1.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
210 BOOST_CHECK(a1.neighborHoodIndices(0, 2).collect() == bins_t({0, 1, 2}));
211 BOOST_CHECK(a1.neighborHoodIndices(1, 2).collect() == bins_t({0, 1, 2, 3}));
212 BOOST_CHECK(a1.neighborHoodIndices(11, 2).collect() == bins_t({9, 10, 11}));
213 BOOST_CHECK(a1.neighborHoodIndices(10, 2).collect() ==
214 bins_t({8, 9, 10, 11}));
215 BOOST_CHECK(a1.neighborHoodIndices(5, 2).collect() ==
216 bins_t({3, 4, 5, 6, 7}));
219 {0.0, 2.0, 4.0, 9.0, 10.0});
220 BOOST_CHECK(a2.neighborHoodIndices(0, 1).collect() == bins_t({0, 1}));
221 BOOST_CHECK(a2.neighborHoodIndices(1, 1).collect() == bins_t({0, 1, 2}));
222 BOOST_CHECK(a2.neighborHoodIndices(5, 1).collect() == bins_t({4, 5}));
223 BOOST_CHECK(a2.neighborHoodIndices(4, 1).collect() == bins_t({3, 4, 5}));
224 BOOST_CHECK(a2.neighborHoodIndices(4, {1, 0}).collect() == bins_t({3, 4}));
225 BOOST_CHECK(a2.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
226 BOOST_CHECK(a2.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
228 BOOST_CHECK(a2.neighborHoodIndices(0, 2).collect() == bins_t({0, 1, 2}));
229 BOOST_CHECK(a2.neighborHoodIndices(1, 2).collect() == bins_t({0, 1, 2, 3}));
230 BOOST_CHECK(a2.neighborHoodIndices(5, 2).collect() == bins_t({3, 4, 5}));
231 BOOST_CHECK(a2.neighborHoodIndices(4, 2).collect() == bins_t({2, 3, 4, 5}));
232 BOOST_CHECK(a2.neighborHoodIndices(3, 2).collect() ==
233 bins_t({1, 2, 3, 4, 5}));
237 BOOST_CHECK(a3.neighborHoodIndices(0, 1).collect() == bins_t({}));
238 BOOST_CHECK(a3.neighborHoodIndices(1, 1).collect() == bins_t({1, 2}));
239 BOOST_CHECK(a3.neighborHoodIndices(11, 1).collect() == bins_t({}));
240 BOOST_CHECK(a3.neighborHoodIndices(10, 1).collect() == bins_t({9, 10}));
241 BOOST_CHECK(a3.neighborHoodIndices(10, {0, 1}).collect() == bins_t({10}));
242 BOOST_CHECK(a3.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
243 BOOST_CHECK(a3.neighborHoodIndices(5, {1, 0}).collect() == bins_t({4, 5}));
244 BOOST_CHECK(a3.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
246 BOOST_CHECK(a3.neighborHoodIndices(0, 2).collect() == bins_t({}));
247 BOOST_CHECK(a3.neighborHoodIndices(1, 2).collect() == bins_t({1, 2, 3}));
248 BOOST_CHECK(a3.neighborHoodIndices(11, 2).collect() == bins_t({}));
249 BOOST_CHECK(a3.neighborHoodIndices(10, 2).collect() == bins_t({8, 9, 10}));
250 BOOST_CHECK(a3.neighborHoodIndices(5, 2).collect() ==
251 bins_t({3, 4, 5, 6, 7}));
255 BOOST_CHECK(a4.neighborHoodIndices(0, 1).collect() == bins_t({}));
256 BOOST_CHECK(a4.neighborHoodIndices(1, 1).collect() == bins_t({10, 1, 2}));
257 BOOST_CHECK(a4.neighborHoodIndices(11, 1).collect() == bins_t({}));
258 BOOST_CHECK(a4.neighborHoodIndices(10, 1).collect() == bins_t({9, 10, 1}));
259 BOOST_CHECK(a4.neighborHoodIndices(10, {0, 1}).collect() == bins_t({10, 1}));
260 BOOST_CHECK(a4.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 6}));
261 BOOST_CHECK(a4.neighborHoodIndices(5, {1, 0}).collect() == bins_t({4, 5}));
262 BOOST_CHECK(a4.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 6}));
264 BOOST_CHECK(a4.neighborHoodIndices(0, 2).collect() == bins_t({}));
265 BOOST_CHECK(a4.neighborHoodIndices(1, 2).collect() ==
266 bins_t({9, 10, 1, 2, 3}));
267 BOOST_CHECK(a4.neighborHoodIndices(11, 2).collect() == bins_t({}));
268 BOOST_CHECK(a4.neighborHoodIndices(10, 2).collect() ==
269 bins_t({8, 9, 10, 1, 2}));
270 BOOST_CHECK(a4.neighborHoodIndices(5, 2).collect() ==
271 bins_t({3, 4, 5, 6, 7}));
274 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
275 BOOST_CHECK(a5.neighborHoodIndices(0, 1).collect() == bins_t({}));
276 BOOST_CHECK(a5.neighborHoodIndices(1, 1).collect() == bins_t({1, 2}));
277 BOOST_CHECK(a5.neighborHoodIndices(6, 1).collect() == bins_t({}));
278 BOOST_CHECK(a5.neighborHoodIndices(5, 1).collect() == bins_t({4, 5}));
279 BOOST_CHECK(a5.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5}));
280 BOOST_CHECK(a5.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
281 BOOST_CHECK(a5.neighborHoodIndices(2, {1, 0}).collect() == bins_t({1, 2}));
282 BOOST_CHECK(a5.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
284 BOOST_CHECK(a5.neighborHoodIndices(0, 2).collect() == bins_t({}));
285 BOOST_CHECK(a5.neighborHoodIndices(1, 2).collect() == bins_t({1, 2, 3}));
286 BOOST_CHECK(a5.neighborHoodIndices(6, 2).collect() == bins_t({}));
287 BOOST_CHECK(a5.neighborHoodIndices(5, 2).collect() == bins_t({3, 4, 5}));
288 BOOST_CHECK(a5.neighborHoodIndices(3, 2).collect() ==
289 bins_t({1, 2, 3, 4, 5}));
292 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
293 BOOST_CHECK(a6.neighborHoodIndices(0, 1).collect() == bins_t({}));
294 BOOST_CHECK(a6.neighborHoodIndices(1, 1).collect() == bins_t({5, 1, 2}));
295 BOOST_CHECK(a6.neighborHoodIndices(6, 1).collect() == bins_t({}));
296 BOOST_CHECK(a6.neighborHoodIndices(5, 1).collect() == bins_t({4, 5, 1}));
297 BOOST_CHECK(a6.neighborHoodIndices(5, {0, 1}).collect() == bins_t({5, 1}));
298 BOOST_CHECK(a6.neighborHoodIndices(2, 1).collect() == bins_t({1, 2, 3}));
299 BOOST_CHECK(a6.neighborHoodIndices(2, {1, 0}).collect() == bins_t({1, 2}));
300 BOOST_CHECK(a6.neighborHoodIndices(2, {0, 1}).collect() == bins_t({2, 3}));
302 BOOST_CHECK(a6.neighborHoodIndices(0, 2).collect() == bins_t({}));
303 BOOST_CHECK(a6.neighborHoodIndices(1, 2).collect() ==
304 bins_t({4, 5, 1, 2, 3}));
305 BOOST_CHECK(a6.neighborHoodIndices(6, 2).collect() == bins_t({}));
306 BOOST_CHECK(a6.neighborHoodIndices(5, 2).collect() ==
307 bins_t({3, 4, 5, 1, 2}));
308 BOOST_CHECK(a6.neighborHoodIndices(3, 2).collect() ==
309 bins_t({1, 2, 3, 4, 5}));
310 BOOST_CHECK(a6.neighborHoodIndices(3, {0, 2}).collect() == bins_t({3, 4, 5}));
312 BOOST_CHECK(a6.neighborHoodIndices(1, 3).collect() ==
313 bins_t({3, 4, 5, 1, 2}));
314 BOOST_CHECK(a6.neighborHoodIndices(5, 3).collect() ==
315 bins_t({2, 3, 4, 5, 1}));
320 BOOST_CHECK_EQUAL(a1.wrapBin(0), 0
u);
321 BOOST_CHECK_EQUAL(a1.wrapBin(1), 1
u);
322 BOOST_CHECK_EQUAL(a1.wrapBin(-1), 0
u);
323 BOOST_CHECK_EQUAL(a1.wrapBin(10), 10
u);
324 BOOST_CHECK_EQUAL(a1.wrapBin(11), 11
u);
325 BOOST_CHECK_EQUAL(a1.wrapBin(12), 11
u);
328 BOOST_CHECK_EQUAL(a2.wrapBin(0), 1
u);
329 BOOST_CHECK_EQUAL(a2.wrapBin(1), 1
u);
330 BOOST_CHECK_EQUAL(a2.wrapBin(-1), 1
u);
331 BOOST_CHECK_EQUAL(a2.wrapBin(10), 10
u);
332 BOOST_CHECK_EQUAL(a2.wrapBin(11), 10
u);
333 BOOST_CHECK_EQUAL(a2.wrapBin(12), 10
u);
336 BOOST_CHECK_EQUAL(a3.wrapBin(0), 10
u);
337 BOOST_CHECK_EQUAL(a3.wrapBin(1), 1
u);
338 BOOST_CHECK_EQUAL(a3.wrapBin(-1), 9
u);
339 BOOST_CHECK_EQUAL(a3.wrapBin(10), 10
u);
340 BOOST_CHECK_EQUAL(a3.wrapBin(11), 1
u);
341 BOOST_CHECK_EQUAL(a3.wrapBin(12), 2
u);
344 {0.0, 2.0, 4.0, 9.0, 10.0});
345 BOOST_CHECK_EQUAL(a4.wrapBin(0), 0
u);
346 BOOST_CHECK_EQUAL(a4.wrapBin(1), 1
u);
347 BOOST_CHECK_EQUAL(a4.wrapBin(-1), 0
u);
348 BOOST_CHECK_EQUAL(a4.wrapBin(4), 4
u);
349 BOOST_CHECK_EQUAL(a4.wrapBin(5), 5
u);
350 BOOST_CHECK_EQUAL(a4.wrapBin(6), 5
u);
353 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
354 BOOST_CHECK_EQUAL(a5.wrapBin(0), 1
u);
355 BOOST_CHECK_EQUAL(a5.wrapBin(1), 1
u);
356 BOOST_CHECK_EQUAL(a5.wrapBin(-1), 1
u);
357 BOOST_CHECK_EQUAL(a5.wrapBin(4), 4
u);
358 BOOST_CHECK_EQUAL(a5.wrapBin(5), 5
u);
359 BOOST_CHECK_EQUAL(a5.wrapBin(6), 5
u);
362 {0.0, 2.0, 4.0, 9.0, 9.5, 10.0});
363 BOOST_CHECK_EQUAL(a6.wrapBin(0), 5
u);
364 BOOST_CHECK_EQUAL(a6.wrapBin(1), 1
u);
365 BOOST_CHECK_EQUAL(a6.wrapBin(-1), 4
u);
366 BOOST_CHECK_EQUAL(a6.wrapBin(4), 4
u);
367 BOOST_CHECK_EQUAL(a6.wrapBin(5), 5
u);
368 BOOST_CHECK_EQUAL(a6.wrapBin(6), 1
u);
369 BOOST_CHECK_EQUAL(a6.wrapBin(7), 2
u);