/* * 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 the _write_font() function. CTEST(styles, write_font01) { char* got; char exp[] = ""; 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, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font02) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_bold(format); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font03) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_italic(format); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font04) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_SINGLE); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font05) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_strikeout(format); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font06) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_script(format, LXW_FONT_SUPERSCRIPT); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font07) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_script(format, LXW_FONT_SUBSCRIPT); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font08) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_name(format, "Arial"); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font09) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_size(format, 12); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font10) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_outline(format); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font11) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_shadow(format); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font12) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_font_color(format, LXW_COLOR_RED); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font13) { char* got; char exp[] = ""; 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, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font14) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_DOUBLE); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font15) { char* got; char exp[] = ""; FILE* testfile = lxw_tmpfile(NULL); lxw_styles *styles = lxw_styles_new(); lxw_format *format = lxw_format_new(); format_set_underline(format, LXW_UNDERLINE_SINGLE_ACCOUNTING); styles->file = testfile; _write_font(styles, format, LXW_FALSE, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font16) { char* got; char exp[] = ""; 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, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); } // Test the _write_font() function. CTEST(styles, write_font17) { char* got; char exp[] = ""; 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, LXW_FALSE); RUN_XLSX_STREQ(exp, got); lxw_styles_free(styles); lxw_format_free(format); }