| 560 | logger dlog("test.serialize"); |
| 561 | |
| 562 | void serialize_test ( |
| 563 | ) |
| 564 | /*! |
| 565 | ensures |
| 566 | - runs tests on the serialization code for compliance with the specs |
| 567 | !*/ |
| 568 | { |
| 569 | |
| 570 | |
| 571 | print_spinner(); |
| 572 | |
| 573 | ostringstream sout; |
| 574 | test_object obj; |
| 575 | |
| 576 | obj.set_state_1(); |
| 577 | obj.assert_in_state_1(); |
| 578 | serialize(obj, sout); |
| 579 | obj.assert_in_state_1(); |
| 580 | |
| 581 | obj.set_state_2(); |
| 582 | obj.assert_in_state_2(); |
| 583 | serialize(obj, sout); |
| 584 | obj.assert_in_state_2(); |
| 585 | |
| 586 | |
| 587 | istringstream sin(sout.str()); |
| 588 | |
| 589 | deserialize(obj,sin); |
| 590 | obj.assert_in_state_1(); |
| 591 | deserialize(obj,sin); |
| 592 | obj.assert_in_state_2(); |
| 593 | |
| 594 | |
| 595 | // now do the same thing as above but deserialize from some stored binary |
| 596 | // data to make sure the serialized values are portable between different |
| 597 | // machines |
| 598 | |
| 599 | sin.clear(); |
| 600 | sin.str(get_decoded_string()); |
| 601 | deserialize(obj,sin); |
| 602 | obj.assert_in_state_1(); |
| 603 | deserialize(obj,sin); |
| 604 | obj.assert_in_state_2(); |
| 605 | |
| 606 | |
| 607 | sin.clear(); |
| 608 | sin.str(get_decoded_string2()); |
| 609 | deserialize(obj,sin); |
| 610 | obj.assert_in_state_1(); |
| 611 | deserialize(obj,sin); |
| 612 | obj.assert_in_state_2(); |
| 613 | |
| 614 | |
| 615 | /* |
| 616 | // This is the code that produced the encoded data stored in the get_decoded_string() function |
| 617 | ofstream fout("stuff.bin",ios::binary); |
| 618 | obj.set_state_1(); |
| 619 | obj.assert_in_state_1(); |
no test coverage detected