diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-23 16:01:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-23 16:01:38 +0100 |
| commit | 5a31b47bc7523a522f9c6c3588133004ba4c578c (patch) | |
| tree | aa60d358963d791cc91f0df78b476a7c0e2bdf30 | |
| parent | 45197b9521ae1004e7b1ce0175897ae4769d298b (diff) | |
Add some more tests.
| -rw-r--r-- | test/dcp_to_stl_binary_test.cc | 30 | ||||
| -rw-r--r-- | test/test.cc | 34 | ||||
| -rw-r--r-- | test/test.h | 1 |
3 files changed, 64 insertions, 1 deletions
diff --git a/test/dcp_to_stl_binary_test.cc b/test/dcp_to_stl_binary_test.cc index 878386c..3f191d5 100644 --- a/test/dcp_to_stl_binary_test.cc +++ b/test/dcp_to_stl_binary_test.cc @@ -26,7 +26,7 @@ using std::ifstream; -BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test) +BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test1) { if (private_test.empty ()) { return; @@ -47,4 +47,32 @@ BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test) "", "", "build/test/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl" ); + + check_file ( + private_test / "fd586c30-6d38-48f2-8241-27359acf184c_sub.stl", + "build/test/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl" + ); +} + +BOOST_AUTO_TEST_CASE (dcp_to_stl_binary_test2) +{ + if (private_test.empty ()) { + return; + } + + boost::filesystem::path p = private_test / "93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.xml"; + ifstream f (p.string().c_str ()); + sub::write_stl_binary ( + sub::collect (sub::DCPReader(f).subtitles ()), + 25, + sub::LANGUAGE_FRENCH, + "", "", + "", "", + "", "", + "300514", "300514", 0, + "GBR", + "", + "", "", + "build/test/93e8a6bf-499e-4d36-9350-a9bfa2e6758a_sub.stl" + ); } diff --git a/test/test.cc b/test/test.cc index 6bb8b5b..272c89a 100644 --- a/test/test.cc +++ b/test/test.cc @@ -27,6 +27,8 @@ using std::string; using std::cerr; +using std::min; +using std::max; using std::ifstream; using std::getline; @@ -76,3 +78,35 @@ check_text (boost::filesystem::path a, boost::filesystem::path b) BOOST_CHECK (p.good() == false); BOOST_CHECK (q.good() == false); } + +void +check_file (boost::filesystem::path ref, boost::filesystem::path check) +{ + uintmax_t N = boost::filesystem::file_size (ref); + BOOST_CHECK_EQUAL (N, boost::filesystem::file_size (check)); + FILE* ref_file = fopen (ref.string().c_str(), "rb"); + BOOST_CHECK (ref_file); + FILE* check_file = fopen (check.string().c_str(), "rb"); + BOOST_CHECK (check_file); + + int const buffer_size = 65536; + uint8_t* ref_buffer = new uint8_t[buffer_size]; + uint8_t* check_buffer = new uint8_t[buffer_size]; + + while (N) { + uintmax_t this_time = min (uintmax_t (buffer_size), N); + size_t r = fread (ref_buffer, 1, this_time, ref_file); + BOOST_CHECK_EQUAL (r, this_time); + r = fread (check_buffer, 1, this_time, check_file); + BOOST_CHECK_EQUAL (r, this_time); + + BOOST_CHECK_EQUAL (memcmp (ref_buffer, check_buffer, this_time), 0); + N -= this_time; + } + + delete[] ref_buffer; + delete[] check_buffer; + + fclose (ref_file); + fclose (check_file); +} diff --git a/test/test.h b/test/test.h index 9d43439..eca271f 100644 --- a/test/test.h +++ b/test/test.h @@ -23,3 +23,4 @@ extern boost::filesystem::path private_test; void check_text (boost::filesystem::path a, boost::filesystem::path b); +void check_file (boost::filesystem::path a, boost::filesystem::path b); |
