src/server/test/xml.c

Sat, 22 Nov 2025 14:27:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 22 Nov 2025 14:27:01 +0100
changeset 633
392ec9026b07
parent 324
44cf877b3d9f
permissions
-rw-r--r--

port old ucx2 tests to ucx3

224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2020 Olaf Wintermann. All rights reserved.
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "xml.h"
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <stdio.h>
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <stdlib.h>
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include <libxml/tree.h>
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "testutils.h"
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include "../public/webdav.h"
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
39 #include "../util/writer.h"
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
40
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
41 #include "../webdav/webdav.h"
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
42 #include "../webdav/xml.h"
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 typedef struct Test1Data {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 int beginCounter;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 int endCounter;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 int elmCounter;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 int endElmCounter;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 int textErr;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 int err;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 int endErr;
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
52 int nodesWithAttributesCounter;
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 xmlNode *prev;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 } Test1Data;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 static int test1_begin(xmlNode *node, void *userdata) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 Test1Data *data = userdata;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 data->beginCounter++;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 if(node->type == XML_ELEMENT_NODE) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 data->elmCounter++;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 const char *name = (const char*)node->name;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 if(!strcmp(name, "ignore") || !strcmp(name, "ignore")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 data->err = 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 return 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 switch(data->elmCounter) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 case 1: if(strcmp(name, "test")){ data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 case 2: if(strcmp(name, "elm1")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 case 3: if(strcmp(name, "elm2")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 case 4: if(strcmp(name, "c")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 case 5: if(strcmp(name, "a")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 case 6: if(strcmp(name, "d")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 case 7: if(strcmp(name, "e")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 case 8: if(strcmp(name, "b")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 case 9: if(strcmp(name, "x")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 case 10: if(strcmp(name, "z")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 case 11: if(strcmp(name, "nextelm")) { data->err = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 } else if(node->type == XML_TEXT_NODE) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 const char *text = (const char*)node->content;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 if(!strcmp(text, "teststr")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 if(strcmp((const char*)data->prev->name, "elm1")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 data->textErr = 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 return 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 } else if(!strcmp(text, "hello") || !strcmp(text, "world")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 if(strcmp((const char*)data->prev->name, "a")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 data->textErr = 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 return 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 if(node->type == XML_ELEMENT_NODE) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 data->prev = node;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 return 0;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 static int test1_end(xmlNode *node, void *userdata) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 Test1Data *data = userdata;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 data->endCounter++;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 if(node->type == XML_ELEMENT_NODE) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 data->endElmCounter++;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 const char *name = (const char*)node->name;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 if(!strcmp(name, "ignore") || !strcmp(name, "ignore")) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 data->err = 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 return 1;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 switch(data->endElmCounter) {
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 case 1: if(strcmp(name, "elm1")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 case 2: if(strcmp(name, "elm2")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 case 3: if(strcmp(name, "a")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 case 4: if(strcmp(name, "b")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 case 5: if(strcmp(name, "e")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 case 6: if(strcmp(name, "d")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 case 7: if(strcmp(name, "c")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 case 8: if(strcmp(name, "z")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 case 9: if(strcmp(name, "x")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 case 10: if(strcmp(name, "test")){ data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 case 11: if(strcmp(name, "nextelm")) { data->endErr = 1; return 1; } break;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 return 0;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 }
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
134 static int test2_begin(xmlNode *node, void *userdata) {
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
135 Test1Data *data = userdata;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
136 data->beginCounter++;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
137 if(node->type == XML_ELEMENT_NODE) {
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
138 data->elmCounter++;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
139 if(node->properties) {
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
140 data->nodesWithAttributesCounter++;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
141 }
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
142 }
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
143 return 0;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
144 }
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
145
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
146 static int test2_end(xmlNode *node, void *userdata) {
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
147 Test1Data *data = userdata;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
148 data->endCounter++;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
149 if(node->type == XML_ELEMENT_NODE) {
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
150 data->endElmCounter++;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
151 }
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
152 return 0;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
153 }
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
154
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
155 CX_TEST(test_wsxml_iterator) {
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 Session *sn = testutil_session();
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
158 CX_TEST_DO {
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
160 xmlDoc *doc = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
161 XML_TESTDATA1, strlen(XML_TESTDATA1), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
162 xmlDoc *doc2 = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
163 XML_TESTDATA2, strlen(XML_TESTDATA2), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
164 xmlDoc *doc6 = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
165 XML_TESTDATA6, strlen(XML_TESTDATA6), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
166 CX_TEST_ASSERT(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
167 CX_TEST_ASSERT(doc2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
168 CX_TEST_ASSERT(doc6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
169
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
170 xmlNode *root = xmlDocGetRootElement(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
171
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
172 // Test 1: iterate over complete document
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
173 Test1Data testdata;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
174 ZERO(&testdata, sizeof(Test1Data));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
175 int ret = wsxml_iterator(sn->pool, root, test1_begin, test1_end, &testdata);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
176 CX_TEST_ASSERT(ret == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
177 CX_TEST_ASSERT(!testdata.err);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
178 CX_TEST_ASSERT(!testdata.endErr);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
179 CX_TEST_ASSERT(!testdata.textErr);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
180 CX_TEST_ASSERT(testdata.beginCounter == testdata.endCounter);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
181
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
182 // Test 2: iterate over sub-document
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
183 ZERO(&testdata, sizeof(Test1Data));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
184 xmlNode *root2 = xmlDocGetRootElement(doc2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
185 xmlNode *sub = root2->children->children;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
186 ret = wsxml_iterator(sn->pool, sub, test1_begin, test1_end, &testdata);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
187 CX_TEST_ASSERT(ret == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
188 CX_TEST_ASSERT(!testdata.err);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
189 CX_TEST_ASSERT(!testdata.endErr);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
190 CX_TEST_ASSERT(!testdata.textErr);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
191 CX_TEST_ASSERT(testdata.beginCounter == testdata.endCounter);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
192
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
193 // Test 3: iterate over document with all kinds of node types
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
194 xmlNode *root6 = xmlDocGetRootElement(doc6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
195 ZERO(&testdata, sizeof(Test1Data));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
196 ret = wsxml_iterator(sn->pool, root6, test2_begin, test2_end, &testdata);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
197 CX_TEST_ASSERT(ret == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
198 CX_TEST_ASSERT(testdata.elmCounter == testdata.endElmCounter);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
199 CX_TEST_ASSERT(testdata.elmCounter == 12);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
200 CX_TEST_ASSERT(testdata.nodesWithAttributesCounter == 5);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
201
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
202 xmlFreeDoc(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
203 xmlFreeDoc(doc2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
204 xmlFreeDoc(doc6);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
205 }
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
206
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
207 testutil_destroy_session(sn);
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 }
225
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
209
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
210 // checks if the namespace list contains the test namespaces x1, x2, x3 and x4
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
211 static void check_ns_list(WebdavNSList *list, int *x1, int *x2, int *x3, int *x4) {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
212 *x1 = 0;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
213 *x2 = 0;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
214 *x3 = 0;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
215 *x4 = 0;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
216
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
217 WebdavNSList *elm = list;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
218 while(elm) {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
219 if(!strcmp((const char*)elm->namespace->prefix, "x1") &&
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
220 !strcmp((const char*)elm->namespace->href, "http://example.com/ns1/"))
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
221 {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
222 *x1 = 1;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
223 } else if(!strcmp((const char*)elm->namespace->prefix, "x2") &&
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
224 !strcmp((const char*)elm->namespace->href, "http://example.com/ns2/"))
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
225 {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
226 *x2 = 1;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
227 } else if(!strcmp((const char*)elm->namespace->prefix, "x3") &&
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
228 !strcmp((const char*)elm->namespace->href, "http://example.com/ns_0/"))
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
229 {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
230 *x3 = 1;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
231 } else if(!strcmp((const char*)elm->namespace->prefix, "x4") &&
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
232 !strcmp((const char*)elm->namespace->href, "http://example.com/ns_0/"))
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
233 {
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
234 *x4 = 1;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
235 }
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
236
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
237 elm = elm->next;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
238 }
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
239 }
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
240
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
241 CX_TEST(test_wsxml_get_required_namespaces) {
225
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
242 Session *sn = testutil_session();
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
243
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
244 CX_TEST_DO {
225
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
245
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
246 xmlDoc *doc3 = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
247 XML_TESTDATA3, strlen(XML_TESTDATA3), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
248 xmlDoc *doc4 = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
249 XML_TESTDATA4, strlen(XML_TESTDATA4), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
250 xmlDoc *doc5 = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
251 XML_TESTDATA5, strlen(XML_TESTDATA5), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
252
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
253 xmlNode *node0 = xmlDocGetRootElement(doc3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
254 xmlNode *node1 = xmlDocGetRootElement(doc3)->children;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
255 xmlNode *node2 = xmlDocGetRootElement(doc4)->children;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
256 xmlNode *node3 = xmlDocGetRootElement(doc5)->children;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
257
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
258 CX_TEST_ASSERT(doc3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
259 CX_TEST_ASSERT(doc4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
260 CX_TEST_ASSERT(doc5);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
261
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
262 int err0, err1, err2, err3;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
263 int x1 = 0;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
264 int x2 = 0;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
265 int x3 = 0;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
266 int x4 = 0;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
267 WebdavNSList *elm = NULL;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
268
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
269 // Test 0:
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
270 WebdavNSList *ns0 = wsxml_get_required_namespaces(sn->pool, node0, &err0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
271 CX_TEST_ASSERT(!err0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
272 CX_TEST_ASSERT(!ns0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
273
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
274 WebdavNSList *ns1 = wsxml_get_required_namespaces(sn->pool, node1, &err1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
275 check_ns_list(ns1, &x1, &x2, &x3, &x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
276 CX_TEST_ASSERT(!err1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
277 CX_TEST_ASSERT(ns1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
278 CX_TEST_ASSERT(x1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
279 CX_TEST_ASSERT(x2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
280 CX_TEST_ASSERT(x3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
281 CX_TEST_ASSERT(x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
282
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
283 WebdavNSList *ns2 = wsxml_get_required_namespaces(sn->pool, node2, &err2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
284 check_ns_list(ns2, &x1, &x2, &x3, &x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
285 CX_TEST_ASSERT(!err2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
286 CX_TEST_ASSERT(ns2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
287 CX_TEST_ASSERT(x1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
288 CX_TEST_ASSERT(x2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
289 CX_TEST_ASSERT(!x3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
290 CX_TEST_ASSERT(!x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
291
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
292 WebdavNSList *ns3 = wsxml_get_required_namespaces(sn->pool, node3, &err3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
293 check_ns_list(ns3, &x1, &x2, &x3, &x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
294 CX_TEST_ASSERT(!err3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
295 CX_TEST_ASSERT(ns3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
296 CX_TEST_ASSERT(x1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
297 CX_TEST_ASSERT(x2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
298 CX_TEST_ASSERT(!x3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
299 CX_TEST_ASSERT(!x4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
300
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
301 xmlFreeDoc(doc3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
302 xmlFreeDoc(doc4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
303 xmlFreeDoc(doc5);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
304 }
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
305
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
306 testutil_destroy_session(sn);
225
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
307 }
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
308
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
309 CX_TEST(test_wsxml_write_nodes) {
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
310 Session *sn = testutil_session();
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
311 TestIOStream *st = testutil_iostream(2048, TRUE);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
312
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
313 CX_TEST_DO {
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
314 xmlDoc *doc = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
315 XML_TESTDATA6, strlen(XML_TESTDATA6), NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
316 CX_TEST_ASSERT(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
317 xmlNode *root = xmlDocGetRootElement(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
318
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
319 Writer writer;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
320 char buffer[1024];
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
321 writer_init(&writer, st, buffer, 1024);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
322
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
323 int err = wsxml_write_nodes(sn->pool, &writer, NULL, root);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
324 writer_flush(&writer);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
325 CX_TEST_ASSERT(err == 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
326 CX_TEST_ASSERT(st->buf->pos > 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
327
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
328 //printf("\n\n");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
329 //printf("%.*s\n", (int)st->buf->size, st->buf->space);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
330 //printf("\n\n");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
331
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
332 xmlDoc *genDoc = xmlReadMemory(
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
333 st->buf->space, st->buf->size, NULL, NULL, 0);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
334 CX_TEST_ASSERT(genDoc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
335
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
336 xmlFreeDoc(doc);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
337 xmlFreeDoc(genDoc);
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
338
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
339 }
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
340 testutil_iostream_destroy(st);
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
341 testutil_destroy_session(sn);
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
342 }
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
343
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
344 CX_TEST(test_wsxml_nslist2string) {
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
345 Session *sn = testutil_session();
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
346
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
347 CX_TEST_DO {
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
348
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
349 WSNamespace ns1;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
350 WSNamespace ns2;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
351 WSNamespace ns3;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
352 memset(&ns1, 0, sizeof(WSNamespace));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
353 memset(&ns2, 0, sizeof(WSNamespace));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
354 memset(&ns3, 0, sizeof(WSNamespace));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
355 ns1.prefix = (const xmlChar*)"x";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
356 ns1.href = (const xmlChar*)"ns1";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
357 ns2.prefix = (const xmlChar*)"y";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
358 ns2.href = (const xmlChar*)"ns2";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
359 ns3.prefix = (const xmlChar*)"z";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
360 ns3.href = (const xmlChar*)"ns3";
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
361
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
362 WebdavNSList elm1 = { &ns1, NULL, NULL };
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
363 WebdavNSList elm2 = { &ns2, NULL, NULL };
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
364 WebdavNSList elm3 = { &ns3, NULL, NULL };
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
365
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
366 // single elm test
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
367 char *str1 = wsxml_nslist2string(sn->pool, &elm1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
368 CX_TEST_ASSERT(str1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
369 CX_TEST_ASSERT(!strcmp(str1, "x:ns1"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
370
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
371 // 2 elm test
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
372 elm1.next = &elm2;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
373 char *str2 = wsxml_nslist2string(sn->pool, &elm1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
374 CX_TEST_ASSERT(str2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
375 CX_TEST_ASSERT(!strcmp(str2, "x:ns1\ny:ns2"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
376
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
377 // 3 elm test
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
378 elm2.next = &elm3;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
379 char *str3 = wsxml_nslist2string(sn->pool, &elm1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
380 CX_TEST_ASSERT(str3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
381 CX_TEST_ASSERT(!strcmp(str3, "x:ns1\ny:ns2\nz:ns3"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
382
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
383 // empty prefix test
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
384 ns1.prefix = NULL;
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
385 char *str4 = wsxml_nslist2string(sn->pool, &elm1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
386 CX_TEST_ASSERT(str4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
387 CX_TEST_ASSERT(!strcmp(str4, ":ns1\ny:ns2\nz:ns3"));
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
388
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
389 }
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
390 testutil_destroy_session(sn);
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
391 }
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
392
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
393 CX_TEST(test_wsxml_string2nslist) {
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
394 Session *sn = testutil_session();
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
395
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
396 CX_TEST_DO {
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
397
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
398 // empty list
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
399 WebdavNSList *list1 = wsxml_string2nslist(sn->pool, "");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
400 CX_TEST_ASSERT(!list1);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
401
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
402 // 1 elm list
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
403 WebdavNSList *list2 = wsxml_string2nslist(sn->pool, "x:ns1");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
404 CX_TEST_ASSERT(list2);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
405 CX_TEST_ASSERT(list2->namespace);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
406 CX_TEST_ASSERT(!strcmp((const char*)list2->namespace->prefix, "x"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
407 CX_TEST_ASSERT(!strcmp((const char*)list2->namespace->href, "ns1"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
408
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
409 // 2 elm list
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
410 WebdavNSList *list3 = wsxml_string2nslist(sn->pool, "x:ns1\ny:ns2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
411 CX_TEST_ASSERT(list3);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
412 CX_TEST_ASSERT(list3->namespace);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
413 CX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
414 CX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
415 CX_TEST_ASSERT(list3->next);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
416 CX_TEST_ASSERT(list3->next->namespace);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
417 CX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
418 CX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"));
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
419
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
420 // empty prefix
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
421 WebdavNSList *list4 = wsxml_string2nslist(sn->pool, ":x\ny:ns2");
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
422 CX_TEST_ASSERT(list4);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
423 CX_TEST_ASSERT(list4->namespace);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
424 CX_TEST_ASSERT(!list4->namespace->prefix);
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
425 CX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"));
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
426
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
427
633
392ec9026b07 port old ucx2 tests to ucx3
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 324
diff changeset
428 }
324
44cf877b3d9f add support for xml properties in propfind/proppatch requests (pg)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 319
diff changeset
429 testutil_destroy_session(sn);
319
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
430 }

mercurial