// Test the _write_font() function. CTEST(styles, write_font13) { char* got; char exp[] = "<font><b/><i/><strike/><outline/><shadow/><u/><vertAlign val=\"superscript\"/><sz val=\"12\"/><color rgb=\"FFFF0000\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_bold(format); format_set_italic(format); format_set_font_size(format, 12); format_set_font_color(format, LXW_COLOR_RED); format_set_font_strikeout(format); format_set_font_outline(format); format_set_font_shadow(format); format_set_font_script(format, LXW_FONT_SUPERSCRIPT); format_set_underline(format, LXW_UNDERLINE_SINGLE); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_style_xf() function. CTEST(styles, write_style_xf) { char* got; char exp[] = "<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); styles->file = testfile; _write_style_xf(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_dxfs() function. CTEST(styles, write_dxfs) { char* got; char exp[] = "<dxfs count=\"0\"/>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); styles->file = testfile; _write_dxfs(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_cell_style() function. CTEST(styles, write_cell_style) { char* got; char exp[] = "<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); styles->file = testfile; _write_cell_style(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_sz() function. CTEST(styles, write_sz) { char* got; char exp[] = "<sz val=\"11\"/>"; FILE* testfile = tmpfile(); lxw_styles *styles = lxw_styles_new(); styles->file = testfile; _write_font_size(styles, 11); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_style_sheet() function. CTEST(styles, write_style_sheet) { char* got; char exp[] = "<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); styles->file = testfile; _write_style_sheet(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_font() function. CTEST(styles, write_font01) { char* got; char exp[] = "<font><sz val=\"11\"/><color theme=\"1\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_cell_xfs() function. CTEST(styles, write_cell_xfs) { char* got; char exp[] = "<cellXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\"/></cellXfs>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); STAILQ_INSERT_TAIL(styles->xf_formats, format, list_pointers); styles->file = testfile; styles->xf_count = 1; _write_cell_xfs(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_font() function. CTEST(styles, write_font16) { char* got; char exp[] = "<font><u val=\"doubleAccounting\"/><sz val=\"11\"/><color theme=\"1\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_DOUBLE_ACCOUNTING); styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }
// Test the _write_font() function. CTEST(styles, write_fonts01) { char* got; char exp[] = "<fonts count=\"1\"><font><sz val=\"11\"/><color theme=\"1\"/><name val=\"Calibri\"/><family val=\"2\"/><scheme val=\"minor\"/></font></fonts>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format->has_font = 1; STAILQ_INSERT_TAIL(styles->xf_formats, format, list_pointers); styles->file = testfile; styles->font_count = 1; _write_fonts(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_borders() function. CTEST(styles, write_borders) { char* got; char exp[] = "<borders count=\"1\"><border><left/><right/><top/><bottom/><diagonal/></border></borders>"; FILE* testfile = tmpfile(); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format->has_border = 1; STAILQ_INSERT_TAIL(styles->xf_formats, format, list_pointers); styles->file = testfile; styles->border_count = 1; _write_borders(styles); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); }
// Test the _write_font() function. CTEST(styles, write_font17) { char* got; char exp[] = "<font><u/><sz val=\"11\"/><color theme=\"10\"/><name val=\"Calibri\"/><family val=\"2\"/></font>"; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_SINGLE); format_set_theme(format, 10); format->hyperlink = 1; styles->file = testfile; _write_font(styles, format, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }