src/server/test/xml.c

Fri, 01 Nov 2024 12:25:52 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 01 Nov 2024 12:25:52 +0100
changeset 562
69fc4ecc5f60
parent 324
44cf877b3d9f
permissions
-rw-r--r--

fix pgext uses a wrong field number, if the column has the same name as a resource or property column

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
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 UCX_TEST(test_wsxml_iterator) {
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
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 UCX_TEST_BEGIN;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 xmlDoc *doc = xmlReadMemory(
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 XML_TESTDATA1, strlen(XML_TESTDATA1), NULL, NULL, 0);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 xmlDoc *doc2 = xmlReadMemory(
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 XML_TESTDATA2, strlen(XML_TESTDATA2), NULL, NULL, 0);
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
164 xmlDoc *doc6 = xmlReadMemory(
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
165 XML_TESTDATA6, strlen(XML_TESTDATA6), NULL, NULL, 0);
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 UCX_TEST_ASSERT(doc, "doc is NULL");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 UCX_TEST_ASSERT(doc2, "doc2 is NULL");
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
168 UCX_TEST_ASSERT(doc6, "doc6 is NULL");
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 xmlNode *root = xmlDocGetRootElement(doc);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 // Test 1: iterate over complete document
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 Test1Data testdata;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 ZERO(&testdata, sizeof(Test1Data));
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 int ret = wsxml_iterator(sn->pool, root, test1_begin, test1_end, &testdata);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 UCX_TEST_ASSERT(ret == 0, "wsxml_iterator failed");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 UCX_TEST_ASSERT(!testdata.err, "wrong element order (begin)");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 UCX_TEST_ASSERT(!testdata.endErr, "wrong element order (end)");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 UCX_TEST_ASSERT(!testdata.textErr, "text order error");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 UCX_TEST_ASSERT(testdata.beginCounter == testdata.endCounter, "begin/end counter not equal");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 // Test 2: iterate over sub-document
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 ZERO(&testdata, sizeof(Test1Data));
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 xmlNode *root2 = xmlDocGetRootElement(doc2);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 xmlNode *sub = root2->children->children;
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 ret = wsxml_iterator(sn->pool, sub, test1_begin, test1_end, &testdata);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 UCX_TEST_ASSERT(ret == 0, "test2: wsxml_iterator failed");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 UCX_TEST_ASSERT(!testdata.err, "test2: wrong element order (begin)");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 UCX_TEST_ASSERT(!testdata.endErr, "test2: wrong element order (end)");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 UCX_TEST_ASSERT(!testdata.textErr, "test2: text order error");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 UCX_TEST_ASSERT(testdata.beginCounter == testdata.endCounter, "test2: begin/end counter not equal");
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
193 // Test 3: iterate over document with all kinds of node types
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
194 xmlNode *root6 = xmlDocGetRootElement(doc6);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
195 ZERO(&testdata, sizeof(Test1Data));
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
196 ret = wsxml_iterator(sn->pool, root6, test2_begin, test2_end, &testdata);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
197 UCX_TEST_ASSERT(ret == 0, "test3: wsxml_iterator failed");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
198 UCX_TEST_ASSERT(testdata.elmCounter == testdata.endElmCounter, "test3: begin/end counter not equal");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
199 UCX_TEST_ASSERT(testdata.elmCounter == 12, "test3: wrong elm counter");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
200 UCX_TEST_ASSERT(testdata.nodesWithAttributesCounter == 5, "test3: wrong entity ref counter");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
201
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 xmlFreeDoc(doc);
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 xmlFreeDoc(doc2);
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
204 xmlFreeDoc(doc6);
224
0de1ec82628e add test for xml iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 UCX_TEST_END;
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
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
241 UCX_TEST(test_wsxml_get_required_namespaces) {
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
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
244 UCX_TEST_BEGIN;
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
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
246 xmlDoc *doc3 = xmlReadMemory(
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
247 XML_TESTDATA3, strlen(XML_TESTDATA3), NULL, NULL, 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
248 xmlDoc *doc4 = xmlReadMemory(
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
249 XML_TESTDATA4, strlen(XML_TESTDATA4), NULL, NULL, 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
250 xmlDoc *doc5 = xmlReadMemory(
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
251 XML_TESTDATA5, strlen(XML_TESTDATA5), NULL, NULL, 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
252
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
253 xmlNode *node0 = xmlDocGetRootElement(doc3);
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
254 xmlNode *node1 = xmlDocGetRootElement(doc3)->children;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
255 xmlNode *node2 = xmlDocGetRootElement(doc4)->children;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
256 xmlNode *node3 = xmlDocGetRootElement(doc5)->children;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
257
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
258 UCX_TEST_ASSERT(doc3, "doc3 is NULL");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
259 UCX_TEST_ASSERT(doc4, "doc4 is NULL");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
260 UCX_TEST_ASSERT(doc5, "doc5 is NULL");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
261
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
262 int err0, err1, err2, err3;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
263 int 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
264 int 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
265 int 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
266 int 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
267 WebdavNSList *elm = NULL;
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
268
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
269 // Test 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
270 WebdavNSList *ns0 = wsxml_get_required_namespaces(sn->pool, node0, &err0);
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
271 UCX_TEST_ASSERT(!err0, "ns0 failed");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
272 UCX_TEST_ASSERT(!ns0, "ns0: nsdefs should be ignored");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
273
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
274 WebdavNSList *ns1 = wsxml_get_required_namespaces(sn->pool, node1, &err1);
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
275 check_ns_list(ns1, &x1, &x2, &x3, &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
276 UCX_TEST_ASSERT(!err1, "ns1 failed");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
277 UCX_TEST_ASSERT(ns1, "ns1: no 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
278 UCX_TEST_ASSERT(x1, "ns1: x1 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
279 UCX_TEST_ASSERT(x2, "ns1: x2 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
280 UCX_TEST_ASSERT(x3, "ns1: x3 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
281 UCX_TEST_ASSERT(x4, "ns1: x4 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
282
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
283 WebdavNSList *ns2 = wsxml_get_required_namespaces(sn->pool, node2, &err2);
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
284 check_ns_list(ns2, &x1, &x2, &x3, &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
285 UCX_TEST_ASSERT(!err2, "ns2 failed");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
286 UCX_TEST_ASSERT(ns2, "ns2: no 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
287 UCX_TEST_ASSERT(x1, "ns2: x1 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
288 UCX_TEST_ASSERT(x2, "ns2: x2 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
289 UCX_TEST_ASSERT(!x3, "ns2: 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
290 UCX_TEST_ASSERT(!x4, "ns2: 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
291
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
292 WebdavNSList *ns3 = wsxml_get_required_namespaces(sn->pool, node3, &err3);
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
293 check_ns_list(ns3, &x1, &x2, &x3, &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
294 UCX_TEST_ASSERT(!err3, "ns3 failed");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
295 UCX_TEST_ASSERT(ns3, "ns3: no 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
296 UCX_TEST_ASSERT(x1, "ns3: x1 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
297 UCX_TEST_ASSERT(x2, "ns3: x2 missing");
e4f3e1433098 add function for getting all namespace definitions that are required for an element
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 224
diff changeset
298 UCX_TEST_ASSERT(!x3, "ns3: 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
299 UCX_TEST_ASSERT(!x4, "ns3: 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
300
232
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
301 xmlFreeDoc(doc3);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
302 xmlFreeDoc(doc4);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
303 xmlFreeDoc(doc5);
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
304 UCX_TEST_END;
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
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
309 UCX_TEST(test_wsxml_write_nodes) {
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
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
313 UCX_TEST_BEGIN;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
314 xmlDoc *doc = xmlReadMemory(
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
315 XML_TESTDATA6, strlen(XML_TESTDATA6), NULL, NULL, 0);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
316 UCX_TEST_ASSERT(doc, "xml parser error");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
317 xmlNode *root = xmlDocGetRootElement(doc);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
318
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
319 Writer writer;
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
320 char buffer[1024];
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
321 writer_init(&writer, st, buffer, 1024);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
322
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
323 int err = wsxml_write_nodes(sn->pool, &writer, NULL, root);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
324 writer_flush(&writer);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
325 UCX_TEST_ASSERT(err == 0, "wsxml_write_nodes error");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
326 UCX_TEST_ASSERT(st->buf->pos > 0, "buffer is empty");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
327
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
328 //printf("\n\n");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
329 //printf("%.*s\n", (int)st->buf->size, st->buf->space);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
330 //printf("\n\n");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
331
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
332 xmlDoc *genDoc = xmlReadMemory(
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
333 st->buf->space, st->buf->size, NULL, NULL, 0);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
334 UCX_TEST_ASSERT(genDoc, "generated doc is not valid xml");
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
335
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
336 xmlFreeDoc(doc);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
337 xmlFreeDoc(genDoc);
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
338
499711b2a970 add xml writer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 225
diff changeset
339 UCX_TEST_END;
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
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
344 UCX_TEST(test_wsxml_nslist2string) {
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
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
347 UCX_TEST_BEGIN;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
348
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
349 WSNamespace ns1;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
350 WSNamespace ns2;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
351 WSNamespace ns3;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
352 memset(&ns1, 0, sizeof(WSNamespace));
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
353 memset(&ns2, 0, sizeof(WSNamespace));
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
354 memset(&ns3, 0, sizeof(WSNamespace));
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
355 ns1.prefix = (const xmlChar*)"x";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
356 ns1.href = (const xmlChar*)"ns1";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
357 ns2.prefix = (const xmlChar*)"y";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
358 ns2.href = (const xmlChar*)"ns2";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
359 ns3.prefix = (const xmlChar*)"z";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
360 ns3.href = (const xmlChar*)"ns3";
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
361
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
362 WebdavNSList elm1 = { &ns1, NULL, NULL };
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
363 WebdavNSList elm2 = { &ns2, NULL, NULL };
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
364 WebdavNSList elm3 = { &ns3, NULL, NULL };
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
365
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
366 // single elm test
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
367 char *str1 = wsxml_nslist2string(sn->pool, &elm1);
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
368 UCX_TEST_ASSERT(str1, "str1 is null");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
369 UCX_TEST_ASSERT(!strcmp(str1, "x:ns1"), "str1: wrong content");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
370
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
371 // 2 elm test
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
372 elm1.next = &elm2;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
373 char *str2 = wsxml_nslist2string(sn->pool, &elm1);
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
374 UCX_TEST_ASSERT(str2, "str2 is null");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
375 UCX_TEST_ASSERT(!strcmp(str2, "x:ns1\ny:ns2"), "str2: wrong content");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
376
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
377 // 3 elm test
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
378 elm2.next = &elm3;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
379 char *str3 = wsxml_nslist2string(sn->pool, &elm1);
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
380 UCX_TEST_ASSERT(str3, "str3 is null");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
381 UCX_TEST_ASSERT(!strcmp(str3, "x:ns1\ny:ns2\nz:ns3"), "str3: wrong content");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
382
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
383 // empty prefix test
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
384 ns1.prefix = NULL;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
385 char *str4 = wsxml_nslist2string(sn->pool, &elm1);
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
386 UCX_TEST_ASSERT(str4, "str3 is null");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
387 UCX_TEST_ASSERT(!strcmp(str4, ":ns1\ny:ns2\nz:ns3"), "str4: wrong content");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
388
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
389 UCX_TEST_END;
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
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
393 UCX_TEST(test_wsxml_string2nslist) {
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
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
396 UCX_TEST_BEGIN;
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
397
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
398 // empty list
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
399 WebdavNSList *list1 = wsxml_string2nslist(sn->pool, "");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
400 UCX_TEST_ASSERT(!list1, "list1 should be NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
401
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
402 // 1 elm list
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
403 WebdavNSList *list2 = wsxml_string2nslist(sn->pool, "x:ns1");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
404 UCX_TEST_ASSERT(list2, "list2 is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
405 UCX_TEST_ASSERT(list2->namespace, "list2 namespace is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
406 UCX_TEST_ASSERT(!strcmp((const char*)list2->namespace->prefix, "x"), "list2: wrong prefix");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
407 UCX_TEST_ASSERT(!strcmp((const char*)list2->namespace->href, "ns1"), "list2: wrong href");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
408
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
409 // 2 elm list
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
410 WebdavNSList *list3 = wsxml_string2nslist(sn->pool, "x:ns1\ny:ns2");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
411 UCX_TEST_ASSERT(list3, "list3 is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
412 UCX_TEST_ASSERT(list3->namespace, "list3 namespace is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
413 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"), "list3: wrong prefix");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
414 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: wrong href");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
415 UCX_TEST_ASSERT(list3->next, "list3 elm2 is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
416 UCX_TEST_ASSERT(list3->next->namespace, "list3 namespace 2 is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
417 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"), "list3: elm2 wrong prefix");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
418 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: elm2 wrong href");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
419
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
420 // empty prefix
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
421 WebdavNSList *list4 = wsxml_string2nslist(sn->pool, ":x\ny:ns2");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
422 UCX_TEST_ASSERT(list4, "list4 is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
423 UCX_TEST_ASSERT(list4->namespace, "list4 namespace is NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
424 UCX_TEST_ASSERT(!list4->namespace->prefix, "list4 elm1 prefix should be NULL");
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
425 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: wrong href");
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
a9b9344875aa add WebdavNSList <-> string converting functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 232
diff changeset
428 UCX_TEST_END;
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