初始化PHP-Xlswrite扩展
This commit is contained in:
15
library/libxlsxwriter/test/unit/sst/main.c
Normal file
15
library/libxlsxwriter/test/unit/sst/main.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Test runner for xmlwriter using ctest.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
#define CTEST_MAIN
|
||||
|
||||
#include "../ctest.h"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return ctest_main(argc, argv);
|
||||
}
|
||||
|
84
library/libxlsxwriter/test/unit/sst/test_shared_strings.c
Normal file
84
library/libxlsxwriter/test/unit/sst/test_shared_strings.c
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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[] =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"7\" uniqueCount=\"3\">"
|
||||
"<si>"
|
||||
"<t>neptune</t>"
|
||||
"</si>"
|
||||
"<si>"
|
||||
"<t>mars</t>"
|
||||
"</si>"
|
||||
"<si>"
|
||||
"<t>venus</t>"
|
||||
"</si>"
|
||||
"</sst>";
|
||||
|
||||
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[] =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"3\" uniqueCount=\"3\">"
|
||||
"<si>"
|
||||
"<t>abcdefg</t>"
|
||||
"</si>"
|
||||
"<si>"
|
||||
"<t xml:space=\"preserve\"> abcdefg</t>"
|
||||
"</si>"
|
||||
"<si>"
|
||||
"<t xml:space=\"preserve\">abcdefg </t>"
|
||||
"</si>"
|
||||
"</sst>";
|
||||
|
||||
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);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../ctest.h"
|
||||
#include "../helper.h"
|
||||
|
||||
#include "../../../include/xlsxwriter/shared_strings.h"
|
||||
|
||||
// Test _xml_declaration().
|
||||
CTEST(sst, xml_declaration) {
|
||||
|
||||
char* got;
|
||||
char exp[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
FILE* testfile = lxw_tmpfile(NULL);
|
||||
|
||||
lxw_sst *sst = lxw_sst_new();
|
||||
sst->file = testfile;
|
||||
|
||||
_sst_xml_declaration(sst);
|
||||
|
||||
RUN_XLSX_STREQ(exp, got);
|
||||
|
||||
lxw_sst_free(sst);
|
||||
}
|
Reference in New Issue
Block a user