5 #include "library/directory.hpp"
8 uint64_t get_file_size(const std::string
& filename
)
10 uintmax_t size
= directory::size(filename
);
11 if(size
== static_cast<uintmax_t>(-1))
19 std::function
<bool()> run
;
22 struct test tests
[] = {
23 {"instance default ctor", []() {
24 rrdata_set::instance i
;
25 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000000";
26 }},{"instance bytes ctor", []() {
27 uint8_t buf
[32] = {0};
29 rrdata_set::instance
i(buf
);
30 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000100";
31 }},{"instance string ctor #1", []() {
32 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000763234676");
33 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000763234676";
34 }},{"instance string ctor #2", []() {
35 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000763afba76");
36 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000763AFBA76";
37 }},{"instance string ctor #3", []() {
38 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000763AFBA76");
39 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000763AFBA76";
41 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000000");
42 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000000");
45 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000000");
46 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000001");
49 rrdata_set::instance
i1("00000000000000000000000000000000000000000000000000000000000000FF");
50 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000100");
53 rrdata_set::instance
i1("00000000000000000000000000000000000000000000000000000000000000FF");
54 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000100");
57 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
58 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000001");
61 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
62 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000101");
65 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
66 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000000");
68 }},{"post-++ #1", []() {
69 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000000");
71 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000001";
72 }},{"post-++ #2", []() {
73 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000001");
75 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000002";
76 }},{"post-++ #3", []() {
77 rrdata_set::instance
i("000000000000000000000000000000000000000000000000000000000000000F");
79 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000010";
80 }},{"post-++ #4", []() {
81 rrdata_set::instance
i("00000000000000000000000000000000000000000000000000000000000000FF");
83 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000100";
84 }},{"post-++ #5", []() {
85 rrdata_set::instance
i("000000000000000000000000000000000000000000000000000000000000FFFF");
87 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000010000";
88 }},{"post-++ #6", []() {
89 rrdata_set::instance
i("000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFF");
91 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000010000000000000000";
92 }},{"post-++ #7", []() {
93 rrdata_set::instance
i("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
95 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000000";
96 }},{"post-++ #8", []() {
97 rrdata_set::instance
i("00000000000000000000000000000000000000000000000000000000000000FE");
99 return (stringfmt() << i
).str() == "00000000000000000000000000000000000000000000000000000000000000FF";
100 }},{"pre-++ #1", []() {
101 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000000");
103 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000001";
104 }},{"pre-++ #2", []() {
105 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000001");
107 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000002";
108 }},{"pre-++ #3", []() {
109 rrdata_set::instance
i("000000000000000000000000000000000000000000000000000000000000000F");
111 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000010";
112 }},{"pre-++ #4", []() {
113 rrdata_set::instance
i("00000000000000000000000000000000000000000000000000000000000000FF");
115 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000100";
116 }},{"pre-++ #5", []() {
117 rrdata_set::instance
i("000000000000000000000000000000000000000000000000000000000000FFFF");
119 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000010000";
120 }},{"pre-++ #6", []() {
121 rrdata_set::instance
i("000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFF");
123 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000010000000000000000";
124 }},{"pre-++ #7", []() {
125 rrdata_set::instance
i("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
127 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000000";
128 }},{"pre-++ #8", []() {
129 rrdata_set::instance
i("00000000000000000000000000000000000000000000000000000000000000FE");
131 return (stringfmt() << i
).str() == "00000000000000000000000000000000000000000000000000000000000000FF";
132 }},{"Operator+ #1", []() {
133 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000000");
135 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000012";
136 }},{"Operator+ #2", []() {
137 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000000");
139 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000001234";
140 }},{"Operator+ #3", []() {
141 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000001");
143 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000000100";
144 }},{"Operator+ #4", []() {
145 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000001");
147 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000010000";
148 }},{"Operator+ #4", []() {
149 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000102");
151 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000000010001";
152 }},{"Operator+ #4", []() {
153 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000002");
155 return (stringfmt() << i
).str() == "0000000000000000000000000000000000000000000000000000000100000001";
156 }},{"Operator- #1", []() {
157 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000002");
158 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
159 return (i1
- i2
) == 0;
160 }},{"Operator- #2", []() {
161 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
162 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
163 return (i1
- i2
) == std::numeric_limits
<unsigned>::max();
164 }},{"Operator- #3", []() {
165 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000002");
166 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000001");
167 return (i1
- i2
) == 1;
168 }},{"Operator- #4", []() {
169 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
170 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000007");
171 return (i1
- i2
) == std::numeric_limits
<unsigned>::max();
172 }},{"Operator- #5", []() {
173 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000236");
174 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000123");
175 return (i1
- i2
) == 0x113;
176 }},{"Operator- #6", []() {
177 rrdata_set::instance
i1("00000000000000000000000000000000000000000000000000000000FFFFFFFE");
178 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000000");
179 return (i1
- i2
) == 0xFFFFFFFEU
;
180 }},{"Operator- #7", []() {
181 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000100000000");
182 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
183 return (i1
- i2
) == 0xFFFFFFFEU
;
184 }},{"Operator- #8", []() {
185 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000001000000001");
186 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
187 return (i1
- i2
) == 0xFFFFFFFFU
;
188 }},{"Operator- #9", []() {
189 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000000");
190 rrdata_set::instance
i2("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
191 return (i1
- i2
) == 1;
192 }},{"rrdata init", []() {
194 return s
.debug_dump() == "0[]";
195 }},{"rrdata add", []() {
196 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
200 return s
.debug_dump() == "1[{0000000000000000000000000000000000000000000000000000000000000002,"
201 "0000000000000000000000000000000000000000000000000000000000000003}]";
202 }},{"rrdata add disjoint", []() {
203 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000002");
204 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000004");
210 return s
.debug_dump() == "2[{0000000000000000000000000000000000000000000000000000000000000002,"
211 "0000000000000000000000000000000000000000000000000000000000000003}{"
212 "0000000000000000000000000000000000000000000000000000000000000004,"
213 "0000000000000000000000000000000000000000000000000000000000000005}]";
214 }},{"rrdata add again", []() {
215 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000002");
221 return s
.debug_dump() == "1[{0000000000000000000000000000000000000000000000000000000000000002,"
222 "0000000000000000000000000000000000000000000000000000000000000003}]";
223 }},{"rrdata extend range low", []() {
224 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000000");
225 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
226 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000004");
229 if(!s
.debug_add(i
)) {
230 std::cout
<< "Collides..." << std::flush
;
233 if(s
.debug_dump() == "4[{0000000000000000000000000000000000000000000000000000000000000000,"
234 "0000000000000000000000000000000000000000000000000000000000000004}]")
236 std::cout
<< s
.debug_dump() << "..." << std::flush
;
238 }},{"rrdata extend range high", []() {
239 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000004");
240 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
241 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000004");
246 return s
.debug_dump() == "4[{0000000000000000000000000000000000000000000000000000000000000001,"
247 "0000000000000000000000000000000000000000000000000000000000000005}]";
248 }},{"rrdata add again (range)", []() {
249 rrdata_set::instance
i("0000000000000000000000000000000000000000000000000000000000000002");
250 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000001");
251 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000004");
256 return s
.debug_dump() == "3[{0000000000000000000000000000000000000000000000000000000000000001,"
257 "0000000000000000000000000000000000000000000000000000000000000004}]";
258 }},{"rrdata partial overlap (previous)", []() {
259 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
260 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000009");
261 rrdata_set::instance
i3("0000000000000000000000000000000000000000000000000000000000000007");
262 rrdata_set::instance
i4("000000000000000000000000000000000000000000000000000000000000000F");
266 return s
.debug_dump() == "10[{0000000000000000000000000000000000000000000000000000000000000005,"
267 "000000000000000000000000000000000000000000000000000000000000000F}]";
268 }},{"rrdata bridging add", []() {
269 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
270 rrdata_set::instance
i2("000000000000000000000000000000000000000000000000000000000000000A");
271 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000B");
272 rrdata_set::instance
i4("000000000000000000000000000000000000000000000000000000000000000F");
273 rrdata_set::instance
i5("000000000000000000000000000000000000000000000000000000000000000A");
278 return s
.debug_dump() == "10[{0000000000000000000000000000000000000000000000000000000000000005,"
279 "000000000000000000000000000000000000000000000000000000000000000F}]";
280 }},{"rrdata bridging add #2", []() {
281 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
282 rrdata_set::instance
i2("000000000000000000000000000000000000000000000000000000000000000A");
283 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000B");
284 rrdata_set::instance
i4("000000000000000000000000000000000000000000000000000000000000000F");
285 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000008");
286 rrdata_set::instance
i6("000000000000000000000000000000000000000000000000000000000000000D");
291 return s
.debug_dump() == "10[{0000000000000000000000000000000000000000000000000000000000000005,"
292 "000000000000000000000000000000000000000000000000000000000000000F}]";
293 }},{"rrdata discontinuous reverse", []() {
294 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
295 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000009");
296 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
297 rrdata_set::instance
i4("000000000000000000000000000000000000000000000000000000000000000F");
301 return s
.debug_dump() == "9[{0000000000000000000000000000000000000000000000000000000000000005,"
302 "0000000000000000000000000000000000000000000000000000000000000009}{"
303 "000000000000000000000000000000000000000000000000000000000000000A,"
304 "000000000000000000000000000000000000000000000000000000000000000F}]";
305 }},{"rrdata elide next #1", []() {
306 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
307 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000010");
308 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
309 rrdata_set::instance
i4("000000000000000000000000000000000000000000000000000000000000000F");
313 return s
.debug_dump() == "11[{0000000000000000000000000000000000000000000000000000000000000005,"
314 "0000000000000000000000000000000000000000000000000000000000000010}]";
315 }},{"rrdata elide next #2", []() {
316 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
317 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000010");
318 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
319 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000010");
323 return s
.debug_dump() == "11[{0000000000000000000000000000000000000000000000000000000000000005,"
324 "0000000000000000000000000000000000000000000000000000000000000010}]";
325 }},{"rrdata elide next multiple", []() {
326 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
327 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
328 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
329 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
330 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
331 rrdata_set::instance
i6("000000000000000000000000000000000000000000000000000000000000002F");
336 return s
.debug_dump() == "75[{0000000000000000000000000000000000000000000000000000000000000005,"
337 "0000000000000000000000000000000000000000000000000000000000000050}]";
338 }},{"rrdata elide next multiple (OOR)", []() {
339 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
340 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
341 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
342 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
343 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
344 rrdata_set::instance
i6("000000000000000000000000000000000000000000000000000000000000002F");
345 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000060");
346 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000070");
352 return s
.debug_dump() == "91[{0000000000000000000000000000000000000000000000000000000000000005,"
353 "0000000000000000000000000000000000000000000000000000000000000050}{"
354 "0000000000000000000000000000000000000000000000000000000000000060,"
355 "0000000000000000000000000000000000000000000000000000000000000070}]";
356 }},{"rrdata elide next onehalf", []() {
357 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
358 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
359 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
360 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
361 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
362 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
367 return s
.debug_dump() == "80[{0000000000000000000000000000000000000000000000000000000000000005,"
368 "0000000000000000000000000000000000000000000000000000000000000055}]";
369 }},{"rrdata elide next onehalf (OOR)", []() {
370 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
371 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
372 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
373 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
374 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
375 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
376 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000056");
377 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000057");
383 return s
.debug_dump() == "81[{0000000000000000000000000000000000000000000000000000000000000005,"
384 "0000000000000000000000000000000000000000000000000000000000000055}{"
385 "0000000000000000000000000000000000000000000000000000000000000056,"
386 "0000000000000000000000000000000000000000000000000000000000000057}]";
387 }},{"rrdata elide next onehalf and prev", []() {
388 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
389 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
390 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
391 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
392 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
393 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
394 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000001");
395 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000006");
401 return s
.debug_dump() == "84[{0000000000000000000000000000000000000000000000000000000000000001,"
402 "0000000000000000000000000000000000000000000000000000000000000055}]";
403 }},{"rrdata elide next onehalf and prev (exact)", []() {
404 rrdata_set::instance
i1("0000000000000000000000000000000000000000000000000000000000000005");
405 rrdata_set::instance
i2("0000000000000000000000000000000000000000000000000000000000000050");
406 rrdata_set::instance
i3("000000000000000000000000000000000000000000000000000000000000000A");
407 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000014");
408 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000020");
409 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
410 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000001");
411 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000005");
417 return s
.debug_dump() == "84[{0000000000000000000000000000000000000000000000000000000000000001,"
418 "0000000000000000000000000000000000000000000000000000000000000055}]";
419 }},{"In set (empty set, empty data)", []() {
421 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
422 return s
.debug_in_set(i6
, i6
);
423 }},{"In set (non empty set, empty data)", []() {
425 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
426 return !s
.debug_in_set(i6
);
427 }},{"In set (empty set, non empty data)", []() {
429 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
430 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000058");
432 return s
.debug_in_set(i7
, i7
);
433 }},{"In set (match)", []() {
435 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
437 return s
.debug_in_set(i6
);
438 }},{"In set (adjacent low)", []() {
440 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
441 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000056");
443 return !s
.debug_in_set(i6
);
444 }},{"In set (adjacent)", []() {
446 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
447 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000056");
449 return !s
.debug_in_set(i7
);
450 }},{"In set (match to larger)", []() {
452 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
453 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000059");
454 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000056");
456 return s
.debug_in_set(i8
);
457 }},{"In set (match to larger, exact end)", []() {
459 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
460 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000059");
461 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000058");
463 return s
.debug_in_set(i8
);
464 }},{"In set (match to larger, multiple)", []() {
466 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000045");
467 rrdata_set::instance
i5("0000000000000000000000000000000000000000000000000000000000000049");
468 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000055");
469 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000059");
470 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000046");
473 return s
.debug_in_set(i8
);
474 }},{"In set (split)", []() {
476 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000045");
477 rrdata_set::instance
i5("000000000000000000000000000000000000000000000000000000000000004F");
478 rrdata_set::instance
i6("0000000000000000000000000000000000000000000000000000000000000050");
479 rrdata_set::instance
i7("0000000000000000000000000000000000000000000000000000000000000059");
480 rrdata_set::instance
i8("0000000000000000000000000000000000000000000000000000000000000046");
481 rrdata_set::instance
i9("0000000000000000000000000000000000000000000000000000000000000053");
484 return !s
.debug_in_set(i8
, i9
);
485 }},{"Set internal, add internal", []() {
487 rrdata_set::instance
i4("0000000000000000000000000000000000000000000000000000000000000045");
490 return s
.debug_dump() == "1[{0000000000000000000000000000000000000000000000000000000000000045,"
491 "0000000000000000000000000000000000000000000000000000000000000046}]";
492 }},{"Empty count", []() {
494 return s
.count() == 0;
495 }},{"count 1 node", []() {
498 return s
.count() == 0;
499 }},{"count 2 node", []() {
503 return s
.count() == 1;
504 }},{"count 3 node", []() {
509 return s
.count() == 2;
510 }},{"Count rrdata #1", []() {
512 std::vector
<char> data
;
513 return s
.count(data
) == 0;
514 }},{"Count rrdata #2", []() {
516 char _data
[] = {0x1F,0x00};
517 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
518 return s
.count(data
) == 0;
519 }},{"Count rrdata #2", []() {
521 char _data
[] = {0x1F,0x00,0x1F,0x02};
522 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
523 return s
.count(data
) == 1;
524 }},{"Count rrdata #3", []() {
526 char _data
[] = {0x3F,0x01,0x07,0x1F,0x12};
527 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
528 return s
.count(data
) == 9;
529 }},{"Count rrdata #4", []() {
531 char _data
[] = {0x5F,0x01,0x07,0x45,0x1F,-1};
532 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
533 return s
.count(data
) == 0x847;
534 }},{"Count rrdata #5", []() {
536 char _data
[] = {0x7F,0x01,0x07,0x45,0x14,0x1F,-1};
537 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
538 return s
.count(data
) == 0x84616;
539 }},{"read rrdata #1", []() {
541 char _data
[] = {0x7F,0x01,0x07,0x45,0x14,0x1F,-1,0x1F,0x00};
542 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
544 std::string ans
= "542232[{0000000000000000000000000000000000000000000000000000000000000001,"
545 "0000000000000000000000000000000000000000000000000000000000084617}{"
546 "00000000000000000000000000000000000000000000000000000000000846FF,"
547 "0000000000000000000000000000000000000000000000000000000000084701}]";
548 return s
.debug_dump() == ans
;
549 }},{"read/write rrdata #1", []() {
551 char _data
[] = {0x7F,0x01,0x07,0x45,0x14,0x1F,-1,0x1F,0x00};
552 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
554 std::vector
<char> data2
;
555 if(s
.write(data2
) != 0x84617)
557 char _data2
[] = {0x7F,0x01,0x07,0x45,0x14,0x3F,-1,0x00};
558 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
560 }},{"Write blank", []() {
562 std::vector
<char> data2
;
565 return data2
.size() == 0;
566 }},{"Write oversize rrdata run", []() {
568 rrdata_set::instance i
;
569 s
.debug_add(i
,i
+ 0x2000000);
570 std::vector
<char> data2
;
571 if(s
.write(data2
) != 0x1FFFFFF)
573 char _data2
[] = {0x7F,0x00,-1,-1,-1,0x7F,0x01,-3,-3,-3};
574 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
576 }},{"Decode split", []() {
578 char _data
[] = {0x7F,0x00,-1,-1,-1,0x7F,0x01,-3,-3,-3};
579 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
581 std::string ans
= "33554432[{0000000000000000000000000000000000000000000000000000000000000000,"
582 "0000000000000000000000000000000000000000000000000000000002000000}]";
583 return s
.debug_dump() == ans
;
584 }},{"Write 0-byte length", []() {
586 rrdata_set::instance i
;
588 std::vector
<char> data2
;
589 if(s
.write(data2
) != 0)
591 char _data2
[] = {0x1F,0x00};
592 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
594 }},{"Write 1-byte length", []() {
596 rrdata_set::instance i
;
597 s
.debug_add(i
,i
+ 0x100);
598 std::vector
<char> data2
;
599 if(s
.write(data2
) != 0xFF)
601 char _data2
[] = {0x3F,0x00,-2};
602 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
604 }},{"Write 2-byte length", []() {
606 rrdata_set::instance i
;
607 s
.debug_add(i
,i
+ 0x10000);
608 std::vector
<char> data2
;
609 if(s
.write(data2
) != 0xFFFF)
611 char _data2
[] = {0x5F,0x00,-2,-2};
612 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
614 }},{"Write 2-byte length #2", []() {
616 rrdata_set::instance i
;
617 s
.debug_add(i
+ 0x1424,i
+ 0x11425);
618 std::vector
<char> data2
;
619 if(s
.write(data2
) != 0x10000)
621 char _data2
[] = {0x5E,0x14, 0x24,-2,-1};
622 return sizeof(_data2
) == data2
.size() && !memcmp(_data2
, &data2
[0], min(sizeof(_data2
),
624 }},{"Basic rrdata with backing file", []() {
627 s
.read_base("foo.tmp", false);
628 s
.set_internal(rrdata_set::instance(
629 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
630 if(get_file_size("foo.tmp") != 0)
633 if(get_file_size("foo.tmp") != 32)
636 if(get_file_size("foo.tmp") != 64)
639 if(get_file_size("foo.tmp") != 96)
642 if(get_file_size("foo.tmp") != 128)
645 if(get_file_size("foo.tmp") != 160)
648 }},{"Reopen backing file", []() {
651 s
.read_base("foo.tmp", false);
652 s
.set_internal(rrdata_set::instance(
653 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
654 if(get_file_size("foo.tmp") != 0)
657 if(get_file_size("foo.tmp") != 32)
660 s
.read_base("foo.tmp", false);
662 if(get_file_size("foo.tmp") != 64)
665 }},{"Close with no project", []() {
670 }},{"Switch to self", []() {
673 s
.read_base("foo.tmp", false);
674 s
.set_internal(rrdata_set::instance(
675 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
677 s
.read_base("foo.tmp", false);
679 return s
.count() == 1;
680 }},{"Switch to another", []() {
684 s
.read_base("foo.tmp", false);
685 s
.set_internal(rrdata_set::instance(
686 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
688 s
.read_base("foo2.tmp", false);
691 //std::cerr << s.debug_dump() << std::endl;
692 return s
.count() == 1;
693 }},{"Lazy mode", []() {
696 s
.read_base("foo.tmp", true);
697 s
.set_internal(rrdata_set::instance(
698 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
701 s
.read_base("foo.tmp", false);
704 if(get_file_size("foo.tmp") != 128)
706 return s
.count() == 3;
707 }},{"Lazy mode with previous file", []() {
711 s
.read_base("foo2.tmp", false);
712 s
.read_base("foo.tmp", true);
713 s
.set_internal(rrdata_set::instance(
714 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD0A"));
717 s
.read_base("foo.tmp", false);
720 if(get_file_size("foo.tmp") != 128)
722 return s
.count() == 3;
723 }},{"Reading a file", []() {
726 s
.read_base("foo.tmp", false);
727 char _data
[] = {0x3F,0x01,0x07,0x1F,0x12};
728 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
730 if(get_file_size("foo.tmp") != 320)
733 }},{"Reading a file /w existing entry", []() {
736 rrdata_set::instance i
;
739 s
.read_base("foo.tmp", false);
740 char _data
[] = {0x3F,0x01,0x07,0x1F,0x12};
741 std::vector
<char> data(_data
, _data
+ sizeof(_data
));
743 if(get_file_size("foo.tmp") != 320)
751 struct test
* t
= tests
;
753 std::cout
<< t
->name
<< "..." << std::flush
;
756 std::cout
<< "\e[32mPASS\e[0m" << std::endl
;
758 std::cout
<< "\e[31mFAILED\e[0m" << std::endl
;
761 } catch(std::exception
& e
) {
762 std::cout
<< "\e[31mEXCEPTION: " << e
.what() << "\e[0m" << std::endl
;
765 std::cout
<< "\e[31mUNKNOWN EXCEPTION\e[0m" << std::endl
;