From b38aa006143abd4f10b7ec32576f5ce2867fa975 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 19 May 2024 21:23:37 +0200 Subject: Basic support for colours in binary STL. --- test/stl_binary_reader_test.cc | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'test/stl_binary_reader_test.cc') diff --git a/test/stl_binary_reader_test.cc b/test/stl_binary_reader_test.cc index 6566c5f..a0469d0 100644 --- a/test/stl_binary_reader_test.cc +++ b/test/stl_binary_reader_test.cc @@ -17,6 +17,7 @@ */ + #include "stl_binary_reader.h" #include "subtitle.h" #include "test.h" @@ -24,10 +25,13 @@ #include #include + using std::ifstream; +using std::make_shared; using std::ofstream; using std::shared_ptr; -using std::make_shared; +using std::vector; + /* Test reading of a binary STL file */ BOOST_AUTO_TEST_CASE (stl_binary_reader_test1) @@ -94,3 +98,36 @@ BOOST_AUTO_TEST_CASE (stl_binary_reader_test3) } } + +BOOST_AUTO_TEST_CASE(stl_binary_reader_with_colour) +{ + auto path = private_test / "at.stl"; + ifstream in(path.string().c_str()); + auto reader = make_shared(in); + + vector reference = { + { 1, 1, 1 }, + { 1, 0, 1 }, + { 1, 1, 1 }, + { 1, 0, 1 }, + { 1, 1, 1 }, + { 1, 1, 0 }, + { 1, 1, 1 }, + { 1, 1, 0 }, + { 1, 1, 1 }, + { 1, 1, 0 }, + { 1, 1, 1 }, + { 1, 1, 0 }, + { 1, 1, 1 }, + { 1, 1, 0 } + }; + + /* Check the first few lines */ + auto subs = reader->subtitles(); + BOOST_REQUIRE(subs.size() >= reference.size()); + + for (size_t i = 0; i < reference.size(); ++i) { + BOOST_CHECK(subs[i].colour == reference[i]); + } +} + -- cgit v1.2.3