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