4 void truncate_past_complete_frame()
7 std::cerr
<< "Test #1: Truncate past complete frame" << std::endl
;
9 std::vector
<uint8_t> state
;
11 m
.readonly_mode(false);
16 in1
= m
.next_input(4);
18 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
19 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
22 in2
= m
.next_input(5);
24 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
31 in1
= m
.next_input(4);
33 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
36 in2
= m
.next_input(5);
38 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
44 in1
= m
.next_input(4);
46 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
49 in2
= m
.next_input(5);
51 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
55 state
= m
.save_state();
59 in1
= m
.next_input(4);
61 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (4)" << std::endl
;
64 in2
= m
.next_input(5);
66 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (4)" << std::endl
;
73 in1
= m
.next_input(4);
75 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (5)" << std::endl
;
78 in2
= m
.next_input(5);
80 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (5)" << std::endl
;
83 m
.restore_state(state
, false);
84 std::vector
<controls_t
> v
= m
.save();
86 std::cerr
<< "FAIL: Unexpected size for movie" << std::endl
;
89 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
90 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
93 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4) {
94 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
97 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6) {
98 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
101 std::cerr
<< "PASS!" << std::endl
;
104 void truncate_past_incomplete_frame()
107 std::cerr
<< "Test #2: Truncate past incomplete frame" << std::endl
;
109 std::vector
<uint8_t> state
;
111 m
.readonly_mode(false);
116 in1
= m
.next_input(4);
118 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
119 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
122 in2
= m
.next_input(5);
124 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
131 in1
= m
.next_input(4);
133 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
136 in2
= m
.next_input(5);
138 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
144 in1
= m
.next_input(4);
146 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
149 in2
= m
.next_input(5);
151 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
157 in1
= m
.next_input(5);
159 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (4)" << std::endl
;
162 in2
= m
.next_input(6);
164 std::cerr
<< "FAIL: Unexpected return for m.next_input(6) (4)" << std::endl
;
167 state
= m
.save_state();
168 //Now we have 2 subframes on 4, 3 on 5 and 1 on 6. Add 1 subframe for 4, 5 and 7.
173 in1
= m
.next_input(4);
175 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (5)" << std::endl
;
178 in1
= m
.next_input(5);
180 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (5)" << std::endl
;
183 in2
= m
.next_input(7);
185 std::cerr
<< "FAIL: Unexpected return for m.next_input(7) (5)" << std::endl
;
192 in1
= m
.next_input(4);
194 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (6)" << std::endl
;
197 in2
= m
.next_input(5);
199 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (6)" << std::endl
;
206 in1
= m
.next_input(4);
208 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (7)" << std::endl
;
211 in2
= m
.next_input(5);
213 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (7)" << std::endl
;
216 m
.restore_state(state
, false);
217 std::vector
<controls_t
> v
= m
.save();
219 std::cerr
<< "FAIL: Unexpected size for movie" << std::endl
;
222 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
223 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
226 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4 || v
[1](6) != 0x8 || v
[1](7) != 0xb) {
227 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
230 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6 || v
[2](6) != 0x8 || v
[2](7) != 0xb) {
231 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
232 std::cerr
<< v
[2](0) << " " << v
[2](4) << " " << v
[2](5) << " " << v
[2](6) << " " << v
[2](7) << std::endl
;
235 if(v
[3](0) != 0 || v
[3](4) != 0x5 || v
[3](5) != 0x7 || v
[3](6) != 0x8 || v
[3](7) != 0xb) {
236 std::cerr
<< "FAIL: Wrong input for second frame third subframe" << std::endl
;
239 std::cerr
<< "PASS!" << std::endl
;
242 void truncate_current_complete_frame()
245 std::cerr
<< "Test #3: Truncate current complete frame" << std::endl
;
247 std::vector
<uint8_t> state
;
249 m
.readonly_mode(false);
254 in1
= m
.next_input(4);
256 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
257 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
260 in2
= m
.next_input(5);
262 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
269 in1
= m
.next_input(4);
271 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
274 in2
= m
.next_input(5);
276 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
282 in1
= m
.next_input(4);
284 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
287 in2
= m
.next_input(5);
289 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
293 state
= m
.save_state();
297 in1
= m
.next_input(4);
299 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (4)" << std::endl
;
302 in2
= m
.next_input(5);
304 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (4)" << std::endl
;
307 m
.restore_state(state
, false);
308 std::vector
<controls_t
> v
= m
.save();
310 std::cerr
<< "FAIL: Unexpected size for movie" << std::endl
;
313 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
314 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
317 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4) {
318 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
321 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6) {
322 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
325 std::cerr
<< "PASS!" << std::endl
;
328 void truncate_current_incomplete_frame()
331 std::cerr
<< "Test #4: Truncate current incomplete frame" << std::endl
;
333 std::vector
<uint8_t> state
;
335 m
.readonly_mode(false);
340 in1
= m
.next_input(4);
342 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
343 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
346 in2
= m
.next_input(5);
348 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
355 in1
= m
.next_input(4);
357 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
360 in2
= m
.next_input(5);
362 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
368 in1
= m
.next_input(4);
370 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
373 in2
= m
.next_input(5);
375 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
381 in1
= m
.next_input(5);
383 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (4)" << std::endl
;
386 in2
= m
.next_input(6);
388 std::cerr
<< "FAIL: Unexpected return for m.next_input(6) (4)" << std::endl
;
391 state
= m
.save_state();
392 //Now we have 2 subframes on 4, 3 on 5 and 1 on 6. Add 1 subframe for 4, 5 and 7.
397 in1
= m
.next_input(4);
399 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (5)" << std::endl
;
402 in1
= m
.next_input(5);
404 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (5)" << std::endl
;
407 in2
= m
.next_input(7);
409 std::cerr
<< "FAIL: Unexpected return for m.next_input(7) (5)" << std::endl
;
412 m
.restore_state(state
, false);
413 std::vector
<controls_t
> v
= m
.save();
415 std::cerr
<< "FAIL: Unexpected size for movie" << std::endl
;
418 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
419 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
422 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4 || v
[1](6) != 0x8 || v
[1](7) != 0xb) {
423 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
426 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6 || v
[2](6) != 0x8 || v
[2](7) != 0xb) {
427 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
428 std::cerr
<< v
[2](0) << " " << v
[2](4) << " " << v
[2](5) << " " << v
[2](6) << " " << v
[2](7) << std::endl
;
431 if(v
[3](0) != 0 || v
[3](4) != 0x5 || v
[3](5) != 0x7 || v
[3](6) != 0x8 || v
[3](7) != 0xb) {
432 std::cerr
<< "FAIL: Wrong input for second frame third subframe" << std::endl
;
435 std::cerr
<< "PASS!" << std::endl
;
438 void truncate_future_complete_frame()
441 std::cerr
<< "Test #5: Truncate future complete frame" << std::endl
;
443 std::vector
<uint8_t> state
;
445 m
.readonly_mode(false);
450 in1
= m
.next_input(4);
452 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
453 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
456 in2
= m
.next_input(5);
458 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
465 in1
= m
.next_input(4);
467 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
470 in2
= m
.next_input(5);
472 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
478 in1
= m
.next_input(4);
480 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
483 in2
= m
.next_input(5);
485 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
489 m
.readonly_mode(true);
493 m
.readonly_mode(false);
494 std::vector
<controls_t
> v
= m
.save();
496 std::cerr
<< "FAIL: Unexpected size for movie" << std::endl
;
499 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
500 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
503 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4) {
504 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
507 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6) {
508 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
511 if(v
[3](0) != 1 || v
[3](4) != 0 || v
[3](5) != 0) {
512 std::cerr
<< "FAIL: Wrong input for third frame" << std::endl
;
515 if(v
[4](0) != 1 || v
[4](4) != 0 || v
[4](5) != 0) {
516 std::cerr
<< "FAIL: Wrong input for fourth frame" << std::endl
;
519 if(v
[5](0) != 1 || v
[5](4) != 0 || v
[5](5) != 0) {
520 std::cerr
<< "FAIL: Wrong input for fifth frame" << std::endl
;
523 std::cerr
<< "PASS!" << std::endl
;
526 void truncate_future_incomplete_frame()
529 std::cerr
<< "Test #6: Truncate future incomplete frame" << std::endl
;
531 std::vector
<uint8_t> state
;
533 m
.readonly_mode(false);
538 in1
= m
.next_input(4);
540 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (1)" << std::endl
;
541 std::cerr
<< "Expected 1, got " << in1
<< "." << std::endl
;
544 in2
= m
.next_input(5);
546 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (1)" << std::endl
;
553 in1
= m
.next_input(4);
555 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (2)" << std::endl
;
558 in2
= m
.next_input(5);
560 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (2)" << std::endl
;
566 in1
= m
.next_input(4);
568 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (3)" << std::endl
;
571 in2
= m
.next_input(5);
573 std::cerr
<< "FAIL: Unexpected return for m.next_input(5) (3)" << std::endl
;
577 m
.readonly_mode(true);
581 in1
= m
.next_input(4);
583 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (4)" << std::endl
;
586 in1
= m
.next_input(4);
588 std::cerr
<< "FAIL: Unexpected return for m.next_input(4) (5)" << std::endl
;
591 m
.readonly_mode(false);
592 std::vector
<controls_t
> v
= m
.save();
594 std::cerr
<< "FAIL: Unexpected size for movie (got " << v
.size() << ")" << std::endl
;
597 if(v
[0](0) != 1 || v
[0](4) != 0x1 || v
[0](5) != 0x2) {
598 std::cerr
<< "FAIL: Wrong input for first frame" << std::endl
;
601 if(v
[1](0) != 1 || v
[1](4) != 0x3 || v
[1](5) != 0x4) {
602 std::cerr
<< "FAIL: Wrong input for second frame first subframe" << std::endl
;
605 if(v
[2](0) != 0 || v
[2](4) != 0x5 || v
[2](5) != 0x6) {
606 std::cerr
<< "FAIL: Wrong input for second frame second subframe" << std::endl
;
609 if(v
[3](0) != 1 || v
[3](4) != 0 || v
[3](5) != 0) {
610 std::cerr
<< "FAIL: Wrong input for third frame" << std::endl
;
613 if(v
[4](0) != 1 || v
[4](4) != 0 || v
[4](5) != 0) {
614 std::cerr
<< "FAIL: Wrong input for fourth frame" << std::endl
;
617 if(v
[5](0) != 1 || v
[5](4) != 0 || v
[5](5) != 0) {
618 std::cerr
<< "FAIL: Wrong input for fifth frame" << std::endl
;
621 if(v
[6](0) != 1 || v
[6](4) != 0 || v
[6](5) != 0) {
622 std::cerr
<< "FAIL: Wrong input for sixth frame" << std::endl
;
625 std::cerr
<< "PASS!" << std::endl
;
630 truncate_past_complete_frame();
631 truncate_past_incomplete_frame();
632 truncate_current_complete_frame();
633 truncate_current_incomplete_frame();
634 truncate_future_complete_frame();
635 truncate_future_incomplete_frame();