/* * Tests for the lib_xlsx_writer library. * * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org * */ #include "../ctest.h" #include "../helper.h" #include "../../../include/xlsxwriter/styles.h" // Test assembling a complete Styles file. CTEST(styles, styles01) { char* got; char exp[] = "\n" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format->has_font = 1; format->has_border = 1; styles->file = testfile; styles->font_count = 1; styles->border_count = 1; styles->fill_count = 2; styles->xf_count = 1; STAILQ_INSERT_TAIL(styles->xf_formats, format, list_pointers); lxw_styles_assemble_xml_file(styles); RUN_XLSX_STREQ_SHORT(exp, got); lxw_styles_free(styles); } // Test assembling a complete Styles file. CTEST(styles, styles02) { char* got; char exp[] = "\n" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format1 = lxw_format_new(); lxw_format *format2 = lxw_format_new(); lxw_format *format3 = lxw_format_new(); lxw_format *format4 = lxw_format_new(); format1->has_font = 1; format1->has_border = 1; format2->bold = 1; format2->font_index = 1; format2->has_font = 1; format3->italic = 1; format3->font_index = 2; format3->has_font = 1; format4->bold = 1; format4->italic = 1; format4->font_index = 3; format4->has_font = 1; styles->file = testfile; styles->font_count = 4; styles->border_count = 1; styles->fill_count = 2; styles->xf_count = 4; STAILQ_INSERT_TAIL(styles->xf_formats, format1, list_pointers); STAILQ_INSERT_TAIL(styles->xf_formats, format2, list_pointers); STAILQ_INSERT_TAIL(styles->xf_formats, format3, list_pointers); STAILQ_INSERT_TAIL(styles->xf_formats, format4, list_pointers); lxw_styles_assemble_xml_file(styles); RUN_XLSX_STREQ_SHORT(exp, got); lxw_styles_free(styles); }