X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fstl_binary_reader_test.cc;h=6566c5f161e0d0ff2b77f672c95cf3c6bb55d5d6;hb=fa12ed65527770e2adf300e39526dd0b36fce8c7;hp=bad4bc43eda493c49f31083712f5fa299e3c4dac;hpb=47727a7c80b60a0fd0ce18d8347b14241fc48f97;p=libsub.git diff --git a/test/stl_binary_reader_test.cc b/test/stl_binary_reader_test.cc index bad4bc4..6566c5f 100644 --- a/test/stl_binary_reader_test.cc +++ b/test/stl_binary_reader_test.cc @@ -24,10 +24,10 @@ #include #include -using std::list; using std::ifstream; using std::ofstream; using std::shared_ptr; +using std::make_shared; /* Test reading of a binary STL file */ BOOST_AUTO_TEST_CASE (stl_binary_reader_test1) @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE (stl_binary_reader_test1) path stl = private_test / "VA_24fps_Reel_6_DE_FR.stl"; ifstream in (stl.string().c_str()); - shared_ptr r (new sub::STLBinaryReader(in)); + auto r = make_shared(in); path dump = path("build") / path("test") / path("VA_24fps_Reel_6_DE_FR.dump"); ofstream dump_stream (dump.string().c_str()); sub::dump (r, dump_stream); @@ -59,12 +59,38 @@ BOOST_AUTO_TEST_CASE (stl_binary_reader_test2) using boost::filesystem::path; path stl = private_test / "VA_24fps_Reel_6_DE_FR.stl"; - FILE* in = fopen (stl.string().c_str(), "rb"); + auto in = fopen (stl.string().c_str(), "rb"); BOOST_REQUIRE (in); - shared_ptr r (new sub::STLBinaryReader(in)); + auto r = make_shared(in); fclose (in); path dump = path("build") / path("test") / path("VA_24fps_Reel_6_DE_FR.dump"); ofstream dump_stream (dump.string().c_str()); sub::dump (r, dump_stream); dump_stream.close (); } + + +/** Test reading a file which raised "Unknown language group code U8" and which has + * bizarre line numbering. + */ +BOOST_AUTO_TEST_CASE (stl_binary_reader_test3) +{ + if (private_test.empty()) { + return; + } + + /* This file has a MNR value of 99, which (as per the spec recommendation) + * we "fix" to 12. But it also has line numbers which start at 99 and go up from there, + * so if we don't also alter the line numbers they end up way off the bottom of the screen. + * Check that the line numbers are brought into the range of our "fix". + */ + + auto path = private_test / "hsk.stl"; + ifstream in (path.string().c_str()); + auto reader = make_shared(in); + for (auto i: reader->subtitles()) { + BOOST_REQUIRE(*i.vertical_position.line >= 0); + BOOST_REQUIRE(*i.vertical_position.line <= 12); + } +} +