/* * Tests for the lib_xlsx_writer library. * * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org * */ #include "../ctest.h" #include "../helper.h" #include "../../../include/xlsxwriter/shared_strings.h" // Test assembling a complete SharedStrings file. CTEST(sst, sst01) { char* got; char exp[] = "\n" "" "" "neptune" "" "" "mars" "" "" "venus" "" ""; FILE* testfile = lxw_tmpfile(NULL); lxw_sst *sst = lxw_sst_new(); sst->file = testfile; lxw_get_sst_index(sst, "neptune", LXW_FALSE); lxw_get_sst_index(sst, "neptune", LXW_FALSE); lxw_get_sst_index(sst, "neptune", LXW_FALSE); lxw_get_sst_index(sst, "mars", LXW_FALSE); lxw_get_sst_index(sst, "mars", LXW_FALSE); lxw_get_sst_index(sst, "venus", LXW_FALSE); lxw_get_sst_index(sst, "venus", LXW_FALSE); lxw_sst_assemble_xml_file(sst); RUN_XLSX_STREQ_SHORT(exp, got); lxw_sst_free(sst); } // Test assembling a complete SharedStrings file. CTEST(sst, sst02) { char* got; char exp[] = "\n" "" "" "abcdefg" "" "" " abcdefg" "" "" "abcdefg " "" ""; FILE* testfile = lxw_tmpfile(NULL); lxw_sst *sst = lxw_sst_new(); sst->file = testfile; // Test strings with whitespace that must be preserved. lxw_get_sst_index(sst, "abcdefg", LXW_FALSE); lxw_get_sst_index(sst, " abcdefg", LXW_FALSE); lxw_get_sst_index(sst, "abcdefg ", LXW_FALSE); lxw_sst_assemble_xml_file(sst); RUN_XLSX_STREQ_SHORT(exp, got); lxw_sst_free(sst); }