diff --git a/source/workbook/tests/test_read.hpp b/source/workbook/tests/test_read.hpp index b81e2bf1..12dcbc87 100644 --- a/source/workbook/tests/test_read.hpp +++ b/source/workbook/tests/test_read.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -500,4 +501,58 @@ public: TS_ASSERT_THROWS(serializer.load_workbook(path), xlnt::invalid_file_exception); } + + + void test_read_shared_strings_with_runs() + { + std::string source = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " string" + " " + " " + ""; + pugi::xml_document xml; + xml.load(source.c_str()); + + xlnt::shared_strings_serializer serializer; + std::vector strings; + serializer.read_shared_strings(xml, strings); + + TS_ASSERT_EQUALS(strings.size(), 1); + TS_ASSERT_EQUALS(strings.front().get_runs().size(), 1); + TS_ASSERT_EQUALS(strings.front().get_runs().front().get_size(), 13); + TS_ASSERT_EQUALS(strings.front().get_runs().front().get_color(), "color"); + TS_ASSERT_EQUALS(strings.front().get_runs().front().get_font(), "font"); + TS_ASSERT_EQUALS(strings.front().get_runs().front().get_family(), 12); + TS_ASSERT_EQUALS(strings.front().get_runs().front().get_scheme(), "scheme"); + + std::string source_bad = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " string" + " " + " " + ""; + pugi::xml_document xml_bad; + xml_bad.load(source_bad.c_str()); + + TS_ASSERT_THROWS(serializer.read_shared_strings(xml_bad, strings), std::runtime_error); + } }; diff --git a/source/workbook/tests/test_write_workbook.hpp b/source/workbook/tests/test_write_workbook.hpp index 68775e05..53aa0203 100644 --- a/source/workbook/tests/test_write_workbook.hpp +++ b/source/workbook/tests/test_write_workbook.hpp @@ -224,7 +224,7 @@ public: auto diff = Helper::compare_xml(expected, xml); TS_ASSERT(diff); } - + private: xlnt::workbook wb_; };