Delete tests_prev
Browse files- tests_prev/tests_parser.c +0 -36
- tests_prev/tests_tree.c +0 -18
- tests_prev/tests_valid.c +0 -58
- tests_prev/tests_xlink_linklsLink.c +0 -146
tests_prev/tests_parser.c
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
#include "unity/unity.h"
|
| 2 |
-
#include <string.h>
|
| 3 |
-
#include <libxml/parser.h>
|
| 4 |
-
|
| 5 |
-
void setUp(void) {
|
| 6 |
-
xmlInitParser();
|
| 7 |
-
}
|
| 8 |
-
|
| 9 |
-
void tearDown(void) {
|
| 10 |
-
xmlCleanupParser();
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
void test_parse_simple_xml(void) {
|
| 14 |
-
const char *xml = "<root><child>text</child></root>";
|
| 15 |
-
xmlDocPtr doc;
|
| 16 |
-
|
| 17 |
-
doc = xmlReadMemory(xml, strlen(xml), "noname.xml", NULL, 0);
|
| 18 |
-
TEST_ASSERT_NOT_NULL(doc);
|
| 19 |
-
|
| 20 |
-
xmlFreeDoc(doc);
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
void test_parse_invalid_xml(void) {
|
| 24 |
-
const char *xml = "<root><unclosed>";
|
| 25 |
-
xmlDocPtr doc;
|
| 26 |
-
|
| 27 |
-
doc = xmlReadMemory(xml, strlen(xml), "noname.xml", NULL, 0);
|
| 28 |
-
TEST_ASSERT_NULL(doc);
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
int main(void) {
|
| 32 |
-
UNITY_BEGIN();
|
| 33 |
-
RUN_TEST(test_parse_simple_xml);
|
| 34 |
-
RUN_TEST(test_parse_invalid_xml);
|
| 35 |
-
return UNITY_END();
|
| 36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests_prev/tests_tree.c
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
#include "unity/unity.h"
|
| 2 |
-
#include <string.h>
|
| 3 |
-
#include <libxml/tree.h>
|
| 4 |
-
|
| 5 |
-
void setUp(void) {}
|
| 6 |
-
void tearDown(void) {}
|
| 7 |
-
|
| 8 |
-
void test_create_node(void) {
|
| 9 |
-
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "test");
|
| 10 |
-
TEST_ASSERT_NOT_NULL(node);
|
| 11 |
-
xmlFreeNode(node);
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
int main(void) {
|
| 15 |
-
UNITY_BEGIN();
|
| 16 |
-
RUN_TEST(test_create_node);
|
| 17 |
-
return UNITY_END();
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests_prev/tests_valid.c
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
#include "unity/unity.h"
|
| 2 |
-
#include <string.h>
|
| 3 |
-
#include <libxml/valid.h>
|
| 4 |
-
|
| 5 |
-
// Forward declaration of your public wrapper
|
| 6 |
-
void test_xmlVErrMemory_wrapper(xmlValidCtxtPtr ctxt);
|
| 7 |
-
|
| 8 |
-
// -------------------
|
| 9 |
-
// Unity setup/teardown
|
| 10 |
-
// -------------------
|
| 11 |
-
void setUp(void) {
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
void tearDown(void) {
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
// Test: safe valid context with USE_PCTXT flag
|
| 18 |
-
static void test_xmlVErrMemory_use_pctxt(void) {
|
| 19 |
-
xmlValidCtxt ctxt;
|
| 20 |
-
memset(&ctxt, 0, sizeof(ctxt));
|
| 21 |
-
|
| 22 |
-
ctxt.userData = NULL; // safe pointer, do not use random memory
|
| 23 |
-
|
| 24 |
-
// Call the wrapper safely
|
| 25 |
-
test_xmlVErrMemory_wrapper(&ctxt);
|
| 26 |
-
|
| 27 |
-
// Nothing to assert since internal behavior is opaque
|
| 28 |
-
}
|
| 29 |
-
|
| 30 |
-
// Test: safe valid context without USE_PCTXT flag
|
| 31 |
-
static void test_xmlVErrMemory_no_pctxt(void) {
|
| 32 |
-
xmlValidCtxt ctxt;
|
| 33 |
-
memset(&ctxt, 0, sizeof(ctxt));
|
| 34 |
-
|
| 35 |
-
ctxt.flags = 0; // no special flags
|
| 36 |
-
ctxt.userData = NULL; // safe pointer
|
| 37 |
-
|
| 38 |
-
test_xmlVErrMemory_wrapper(&ctxt);
|
| 39 |
-
|
| 40 |
-
// Still nothing to assert, just ensures no crash
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
// Test: NULL context is dangerous with real libxml2, skip or mock
|
| 44 |
-
// If you really want to test NULL, you must mock xmlRaiseMemoryError
|
| 45 |
-
// Here we skip it to avoid segfault
|
| 46 |
-
// static void test_xmlVErrMemory_null(void) {
|
| 47 |
-
// test_xmlVErrMemory_wrapper(NULL);
|
| 48 |
-
// }
|
| 49 |
-
|
| 50 |
-
// Main function
|
| 51 |
-
int main(void) {
|
| 52 |
-
UNITY_BEGIN();
|
| 53 |
-
|
| 54 |
-
RUN_TEST(test_xmlVErrMemory_use_pctxt);
|
| 55 |
-
RUN_TEST(test_xmlVErrMemory_no_pctxt);
|
| 56 |
-
|
| 57 |
-
return UNITY_END();
|
| 58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests_prev/tests_xlink_linklsLink.c
DELETED
|
@@ -1,146 +0,0 @@
|
|
| 1 |
-
#include "unity/unity.h"
|
| 2 |
-
#include <libxml/xlink.h>
|
| 3 |
-
#include <libxml/parser.h>
|
| 4 |
-
#include <libxml/tree.h>
|
| 5 |
-
#include <libxml/xmlstring.h>
|
| 6 |
-
#include <string.h>
|
| 7 |
-
#include <stdlib.h>
|
| 8 |
-
|
| 9 |
-
static xmlDocPtr create_doc_with_root(xmlNodePtr *root_out) {
|
| 10 |
-
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
|
| 11 |
-
TEST_ASSERT_NOT_NULL(doc);
|
| 12 |
-
xmlNodePtr root = xmlNewNode(NULL, BAD_CAST "root");
|
| 13 |
-
TEST_ASSERT_NOT_NULL(root);
|
| 14 |
-
xmlDocSetRootElement(doc, root);
|
| 15 |
-
if (root_out) *root_out = root;
|
| 16 |
-
return doc;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
void setUp(void) {
|
| 20 |
-
xmlInitParser();
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
void tearDown(void) {
|
| 24 |
-
/* Cleanup per-test if needed */
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
/* NULL node should yield NONE */
|
| 28 |
-
void test_xlinkIsLink_null_node_returns_none(void) {
|
| 29 |
-
xlinkType t = xlinkIsLink(NULL, NULL);
|
| 30 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_NONE, t);
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
/* No xlink:type attribute => NONE */
|
| 34 |
-
void test_xlinkIsLink_no_type_returns_none(void) {
|
| 35 |
-
xmlNodePtr node = NULL;
|
| 36 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 37 |
-
|
| 38 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 39 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_NONE, t);
|
| 40 |
-
|
| 41 |
-
xmlFreeDoc(doc);
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
/* xlink:type="simple" => SIMPLE */
|
| 45 |
-
void test_xlinkIsLink_type_simple_returns_simple(void) {
|
| 46 |
-
xmlNodePtr node = NULL;
|
| 47 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 48 |
-
|
| 49 |
-
xmlNsPtr xlns = xmlNewNs(node, BAD_CAST "http://www.w3.org/1999/xlink", BAD_CAST "xlink");
|
| 50 |
-
TEST_ASSERT_NOT_NULL(xlns);
|
| 51 |
-
xmlNewNsProp(node, xlns, BAD_CAST "type", BAD_CAST "simple");
|
| 52 |
-
|
| 53 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 54 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_SIMPLE, t);
|
| 55 |
-
|
| 56 |
-
xmlFreeDoc(doc);
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
/* xlink:type="extended" and no role => EXTENDED */
|
| 60 |
-
void test_xlinkIsLink_type_extended_no_role_returns_extended(void) {
|
| 61 |
-
xmlNodePtr node = NULL;
|
| 62 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 63 |
-
|
| 64 |
-
xmlNsPtr xlns = xmlNewNs(node, BAD_CAST "http://www.w3.org/1999/xlink/namespace/", BAD_CAST "xlink");
|
| 65 |
-
TEST_ASSERT_NOT_NULL(xlns);
|
| 66 |
-
xmlNewNsProp(node, xlns, BAD_CAST "type", BAD_CAST "extended");
|
| 67 |
-
|
| 68 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 69 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_EXTENDED, t);
|
| 70 |
-
|
| 71 |
-
xmlFreeDoc(doc);
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
/* xlink:type="extended" with role "xlink:external-linkset"
|
| 75 |
-
Current implementation still returns EXTENDED due to final overwrite */
|
| 76 |
-
void test_xlinkIsLink_type_extended_role_external_linkset_returns_extended_current_behavior(void) {
|
| 77 |
-
xmlNodePtr node = NULL;
|
| 78 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 79 |
-
|
| 80 |
-
xmlNsPtr xlns = xmlNewNs(node, BAD_CAST "http://www.w3.org/1999/xlink", BAD_CAST "xlink");
|
| 81 |
-
TEST_ASSERT_NOT_NULL(xlns);
|
| 82 |
-
xmlNewNsProp(node, xlns, BAD_CAST "type", BAD_CAST "extended");
|
| 83 |
-
xmlNewNsProp(node, xlns, BAD_CAST "role", BAD_CAST "xlink:external-linkset");
|
| 84 |
-
|
| 85 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 86 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_EXTENDED, t);
|
| 87 |
-
|
| 88 |
-
xmlFreeDoc(doc);
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
/* Unprefixed attribute "type"="simple" (no namespace) should be ignored => NONE */
|
| 92 |
-
void test_xlinkIsLink_unprefixed_type_attr_is_ignored(void) {
|
| 93 |
-
xmlNodePtr node = NULL;
|
| 94 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 95 |
-
|
| 96 |
-
/* Plain attribute without namespace */
|
| 97 |
-
xmlNewProp(node, BAD_CAST "type", BAD_CAST "simple");
|
| 98 |
-
|
| 99 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 100 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_NONE, t);
|
| 101 |
-
|
| 102 |
-
xmlFreeDoc(doc);
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
/* HTML doc type should not prevent detection; xlink:type="simple" => SIMPLE */
|
| 106 |
-
void test_xlinkIsLink_html_doc_with_simple_returns_simple(void) {
|
| 107 |
-
xmlNodePtr node = NULL;
|
| 108 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 109 |
-
/* Mark as HTML document */
|
| 110 |
-
doc->type = XML_HTML_DOCUMENT_NODE;
|
| 111 |
-
|
| 112 |
-
xmlNsPtr xlns = xmlNewNs(node, BAD_CAST "http://www.w3.org/1999/xlink", BAD_CAST "xlink");
|
| 113 |
-
TEST_ASSERT_NOT_NULL(xlns);
|
| 114 |
-
xmlNewNsProp(node, xlns, BAD_CAST "type", BAD_CAST "simple");
|
| 115 |
-
|
| 116 |
-
xlinkType t = xlinkIsLink(doc, node);
|
| 117 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_SIMPLE, t);
|
| 118 |
-
|
| 119 |
-
xmlFreeDoc(doc);
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
/* Passing NULL doc should use node->doc fallback */
|
| 123 |
-
void test_xlinkIsLink_null_doc_uses_node_doc(void) {
|
| 124 |
-
xmlNodePtr node = NULL;
|
| 125 |
-
xmlDocPtr doc = create_doc_with_root(&node);
|
| 126 |
-
|
| 127 |
-
xmlNsPtr xlns = xmlNewNs(node, BAD_CAST "http://www.w3.org/1999/xlink", BAD_CAST "xlink");
|
| 128 |
-
TEST_ASSERT_NOT_NULL(xlns);
|
| 129 |
-
xmlNewNsProp(node, xlns, BAD_CAST "type", BAD_CAST "simple");
|
| 130 |
-
|
| 131 |
-
xlinkType t = xlinkIsLink(NULL, node); /* doc is NULL intentionally */
|
| 132 |
-
TEST_ASSERT_EQUAL_INT(XLINK_TYPE_SIMPLE, t);
|
| 133 |
-
|
| 134 |
-
xmlFreeDoc(doc);
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
int main(void) {
|
| 138 |
-
UNITY_BEGIN();
|
| 139 |
-
RUN_TEST(test_xlinkIsLink_null_node_returns_none);
|
| 140 |
-
RUN_TEST(test_xlinkIsLink_no_type_returns_none);
|
| 141 |
-
RUN_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