test writing styled text

This commit is contained in:
Thomas Fussell 2016-07-19 20:27:14 -04:00
parent d29a5f0245
commit 4b34273f1b

View File

@ -3,6 +3,7 @@
#include <iostream> #include <iostream>
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include <detail/shared_strings_serializer.hpp>
#include <detail/workbook_serializer.hpp> #include <detail/workbook_serializer.hpp>
#include <helpers/path_helper.hpp> #include <helpers/path_helper.hpp>
#include <xlnt/utils/exceptions.hpp> #include <xlnt/utils/exceptions.hpp>
@ -184,6 +185,45 @@ public:
auto diff = Helper::compare_xml(expected, observed); auto diff = Helper::compare_xml(expected, observed);
TS_ASSERT(diff); TS_ASSERT(diff);
} }
void test_write_shared_strings_with_runs()
{
xlnt::workbook wb;
auto ws = wb.get_active_sheet();
auto cell = ws.get_cell("A1");
xlnt::text_run run;
run.set_color("color");
run.set_family(12);
run.set_font("font");
run.set_scheme("scheme");
run.set_size(13);
run.set_string("string");
xlnt::text text;
text.add_run(run);
cell.set_value(text);
xlnt::shared_strings_serializer serializer;
pugi::xml_document xml;
serializer.write_shared_strings(wb.get_shared_strings(), xml);
std::string expected =
"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"1\" uniqueCount=\"1\">"
" <si>"
" <r>"
" <rPr>"
" <sz val=\"13\"/>"
" <color rgb=\"color\"/>"
" <rFont val=\"font\"/>"
" <family val=\"12\"/>"
" <scheme val=\"scheme\"/>"
" </rPr>"
" <t>string</t>"
" </r>"
" </si>"
"</sst>";
auto diff = Helper::compare_xml(expected, xml);
TS_ASSERT(diff);
}
private: private:
xlnt::workbook wb_; xlnt::workbook wb_;