# # # patch "ChangeLog" # from [b15372578e655bcdf37e95ea35b009737b1ffffb] # to [171769ee270942f5e1ba152b15c881d57e43c775] # # patch "basic_io.cc" # from [042b1a77b3120f06c9744193d166942a88c9da14] # to [6e6babfdc814a224d16a28748222f7ba164893e5] # ============================================================ --- ChangeLog b15372578e655bcdf37e95ea35b009737b1ffffb +++ ChangeLog 171769ee270942f5e1ba152b15c881d57e43c775 @@ -1,6 +1,7 @@ 2006-12-18 Christof Petig * basic_io.hh (peek): use widen to distinguish '\xff' and EOF + * basic_io.cc (binary_transparency): add an unit test for this 2006-12-18 Matt Johnston ============================================================ --- basic_io.cc 042b1a77b3120f06c9744193d166942a88c9da14 +++ basic_io.cc 6e6babfdc814a224d16a28748222f7ba164893e5 @@ -176,6 +176,32 @@ string basic_io::parser::tt2str(token_ty return "TOK_UNKNOWN"; } +#ifdef BUILD_UNIT_TESTS +#include "unit_tests.hh" + +UNIT_TEST(basic_io, binary_transparency) +{ + std::string testpattern; + for (unsigned i=0; i<256; ++i) testpattern+=char(i); + + static symbol test("test"); + + basic_io::printer printer; + basic_io::stanza st; + st.push_str_pair(test, testpattern); + printer.print_stanza(st); + + basic_io::input_source source(printer.buf, "unit test string"); + basic_io::tokenizer tokenizer(source); + basic_io::parser parser(tokenizer); + std::string t1; + parser.esym(test); + parser.str(t1); + I(testpattern==t1); +} + +#endif // BUILD_UNIT_TESTS + // Local Variables: // mode: C++ // fill-column: 76