功能: 服务端生成完整报告并保护单任务

- 使用 libxlsxwriter 常量内存导出 Excel\n- 增加全局任务占用提示与原始数据持久化\n- 保留运行时任务数据并更新接口文档
This commit is contained in:
cloud
2026-08-05 16:47:31 +08:00
parent 07274797af
commit 99ed321d24
2292 changed files with 134317 additions and 126 deletions
@@ -0,0 +1,8 @@
###############################################################################
#
# Makefile for libxlsxwriter library.
#
# Copyright 2014-2022, John McNamara, jmcnamara@cpan.org
#
include ../Makefile.unit
@@ -0,0 +1,15 @@
/*
* Test runner for xmlwriter using ctest.
*
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org
*
*/
#define CTEST_MAIN
#include "../ctest.h"
int main(int argc, const char *argv[])
{
return ctest_main(argc, argv);
}
@@ -0,0 +1,226 @@
/*
* Tests for xmlwriter.
*
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org
*
*/
#include "../ctest.h"
#include "../helper.h"
#include "../../../include/xlsxwriter/xmlwriter.h"
// Test _xml_declaration().
CTEST(xmlwriter, xml_declaration) {
char* got;
char exp[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
FILE* testfile = lxw_tmpfile(NULL);
lxw_xml_declaration(testfile);
RUN_XLSX_STREQ(exp, got);
}
// Test _xml_start_tag() with no attributes.
CTEST(xmlwriter, xml_start_tag) {
char* got;
char exp[] = "<foo>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_xml_start_tag(testfile, "foo", NULL);
RUN_XLSX_STREQ(exp, got);
}
// Test _xml_start_tag() with attributes.
CTEST(xmlwriter, xml_start_tag_with_attributes) {
char* got;
char exp[] = "<foo span=\"8\" baz=\"7\">";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "8");
LXW_PUSH_ATTRIBUTES_STR("baz", "7");
lxw_xml_start_tag(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_start_tag() with attributes requiring escaping.
CTEST(xmlwriter, xml_start_tag_with_attributes_to_escape) {
char* got;
char exp[] = "<foo span=\"&amp;&lt;&gt;&quot;\">";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "&<>\"");
lxw_xml_start_tag(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_start_tag_unencoded() with attributes.
CTEST(xmlwriter, xml_start_tag_unencoded) {
char* got;
char exp[] = "<foo span=\"&<>\"\">";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "&<>\"");
lxw_xml_start_tag_unencoded(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_end_tag().
CTEST(xmlwriter, xml_end_tag) {
char* got;
char exp[] = "</foo>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_xml_end_tag(testfile, "foo");
RUN_XLSX_STREQ(exp, got);
}
// Test _xml_empty_tag() with no attributes.
CTEST(xmlwriter, xml_empty_tag) {
char* got;
char exp[] = "<foo/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_xml_empty_tag(testfile, "foo", NULL);
RUN_XLSX_STREQ(exp, got);
}
// Test _xml_empty_tag() with attributes.
CTEST(xmlwriter, xml_empty_tag_with_attributes) {
char* got;
char exp[] = "<foo span=\"8\" baz=\"7\"/>";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "8");
LXW_PUSH_ATTRIBUTES_STR("baz", "7");
lxw_xml_empty_tag(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_empty_tag() with attributes requiring escaping.
CTEST(xmlwriter, xml_empty_tag_with_attributes_to_escape) {
char* got;
char exp[] = "<foo span=\"&amp;&lt;&gt;&quot;\"/>";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "&<>\"");
lxw_xml_empty_tag(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_empty_tag_unencoded() with attributes.
CTEST(xmlwriter, xml_empty_tag_unencoded) {
char* got;
char exp[] = "<foo span=\"&<>\"\"/>";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "&<>\"");
lxw_xml_empty_tag_unencoded(testfile, "foo", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_empty_tag() with no attributes.
CTEST(xmlwriter, xml_data_element) {
char* got;
char exp[] = "<foo>bar</foo>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_xml_data_element(testfile, "foo", "bar", NULL);
RUN_XLSX_STREQ(exp, got);
}
// Test _xml_data_element() with attributes.
CTEST(xmlwriter, xml_data_element_with_attributes) {
char* got;
char exp[] = "<foo span=\"8\">bar</foo>";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "8");
lxw_xml_data_element(testfile, "foo", "bar", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}
// Test _xml_data_element() with data requiring escaping.
CTEST(xmlwriter, xml_data_element_with_escapes) {
char* got;
char exp[] = "<foo span=\"8\">&amp;&lt;&gt;\"</foo>";
FILE* testfile = lxw_tmpfile(NULL);
struct xml_attribute_list attributes;
struct xml_attribute *attribute;
LXW_INIT_ATTRIBUTES();
LXW_PUSH_ATTRIBUTES_STR("span", "8");
lxw_xml_data_element(testfile, "foo", "&<>\"", &attributes);
RUN_XLSX_STREQ(exp, got);
LXW_FREE_ATTRIBUTES();
}