TextInputStreamTest.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <boost/test/unit_test.hpp>
  2. #include "../TextInputStream.h"
  3. using namespace vconnect;
  4. BOOST_AUTO_TEST_SUITE(TextInputStreamTest)
  5. BOOST_AUTO_TEST_CASE(testTextInputStreamShiftJIS)
  6. {
  7. TextInputStream reader( "fixture/TextInputStream/shift_jis_crlf.txt", "Shift_JIS" );
  8. BOOST_CHECK( true == reader.ready() );
  9. string actual;
  10. string expected;
  11. actual = reader.readLine();
  12. expected = "だ・い・じ・け・ん";
  13. BOOST_CHECK_EQUAL( expected, actual );
  14. BOOST_CHECK( true == reader.ready() );
  15. actual = reader.readLine();
  16. expected = "社会復帰できなくなっちゃうよ";
  17. BOOST_CHECK_EQUAL( expected, actual );
  18. BOOST_CHECK( false == reader.ready() );
  19. }
  20. BOOST_AUTO_TEST_CASE(testTextInputStreamUTF8)
  21. {
  22. TextInputStream *textInputStream = new TextInputStream( "fixture/TextInputStream/utf8_lf.txt", "UTF-8" );
  23. InputStream *reader = (InputStream *)textInputStream;
  24. BOOST_CHECK( true == reader->ready() );
  25. string actual;
  26. string expected;
  27. BOOST_CHECK( true == reader->ready() );
  28. actual = reader->readLine();
  29. expected = "吾輩は猫である。名前はまだ無い。";
  30. BOOST_CHECK_EQUAL( expected, actual );
  31. BOOST_CHECK( true == reader->ready() );
  32. actual = reader->readLine();
  33. expected = "どこで生れたかとんと見当がつかぬ。";
  34. BOOST_CHECK_EQUAL( expected, actual );
  35. BOOST_CHECK( false == reader->ready() );
  36. delete textInputStream;
  37. }
  38. BOOST_AUTO_TEST_SUITE_END()