332 xmlFreeDoc(doc); |
336 xmlFreeDoc(doc); |
333 xmlFreeDoc(genDoc); |
337 xmlFreeDoc(genDoc); |
334 |
338 |
335 UCX_TEST_END; |
339 UCX_TEST_END; |
336 testutil_iostream_destroy(st); |
340 testutil_iostream_destroy(st); |
337 } |
341 testutil_destroy_session(sn); |
|
342 } |
|
343 |
|
344 UCX_TEST(test_wsxml_nslist2string) { |
|
345 Session *sn = testutil_session(); |
|
346 |
|
347 UCX_TEST_BEGIN; |
|
348 |
|
349 WSNamespace ns1; |
|
350 WSNamespace ns2; |
|
351 WSNamespace ns3; |
|
352 memset(&ns1, 0, sizeof(WSNamespace)); |
|
353 memset(&ns2, 0, sizeof(WSNamespace)); |
|
354 memset(&ns3, 0, sizeof(WSNamespace)); |
|
355 ns1.prefix = (const xmlChar*)"x"; |
|
356 ns1.href = (const xmlChar*)"ns1"; |
|
357 ns2.prefix = (const xmlChar*)"y"; |
|
358 ns2.href = (const xmlChar*)"ns2"; |
|
359 ns3.prefix = (const xmlChar*)"z"; |
|
360 ns3.href = (const xmlChar*)"ns3"; |
|
361 |
|
362 WebdavNSList elm1 = { &ns1, NULL, NULL }; |
|
363 WebdavNSList elm2 = { &ns2, NULL, NULL }; |
|
364 WebdavNSList elm3 = { &ns3, NULL, NULL }; |
|
365 |
|
366 // single elm test |
|
367 char *str1 = wsxml_nslist2string(sn->pool, &elm1); |
|
368 UCX_TEST_ASSERT(str1, "str1 is null"); |
|
369 UCX_TEST_ASSERT(!strcmp(str1, "x:ns1"), "str1: wrong content"); |
|
370 |
|
371 // 2 elm test |
|
372 elm1.next = &elm2; |
|
373 char *str2 = wsxml_nslist2string(sn->pool, &elm1); |
|
374 UCX_TEST_ASSERT(str2, "str2 is null"); |
|
375 UCX_TEST_ASSERT(!strcmp(str2, "x:ns1\ny:ns2"), "str2: wrong content"); |
|
376 |
|
377 // 3 elm test |
|
378 elm2.next = &elm3; |
|
379 char *str3 = wsxml_nslist2string(sn->pool, &elm1); |
|
380 UCX_TEST_ASSERT(str3, "str3 is null"); |
|
381 UCX_TEST_ASSERT(!strcmp(str3, "x:ns1\ny:ns2\nz:ns3"), "str3: wrong content"); |
|
382 |
|
383 // empty prefix test |
|
384 ns1.prefix = NULL; |
|
385 char *str4 = wsxml_nslist2string(sn->pool, &elm1); |
|
386 UCX_TEST_ASSERT(str4, "str3 is null"); |
|
387 UCX_TEST_ASSERT(!strcmp(str4, ":ns1\ny:ns2\nz:ns3"), "str4: wrong content"); |
|
388 |
|
389 UCX_TEST_END; |
|
390 testutil_destroy_session(sn); |
|
391 } |
|
392 |
|
393 UCX_TEST(test_wsxml_string2nslist) { |
|
394 Session *sn = testutil_session(); |
|
395 |
|
396 UCX_TEST_BEGIN; |
|
397 |
|
398 // empty list |
|
399 WebdavNSList *list1 = wsxml_string2nslist(sn->pool, ""); |
|
400 UCX_TEST_ASSERT(!list1, "list1 should be NULL"); |
|
401 |
|
402 // 1 elm list |
|
403 WebdavNSList *list2 = wsxml_string2nslist(sn->pool, "x:ns1"); |
|
404 UCX_TEST_ASSERT(list2, "list2 is NULL"); |
|
405 UCX_TEST_ASSERT(list2->namespace, "list2 namespace is NULL"); |
|
406 UCX_TEST_ASSERT(!strcmp((const char*)list2->namespace->prefix, "x"), "list2: wrong prefix"); |
|
407 UCX_TEST_ASSERT(!strcmp((const char*)list2->namespace->href, "ns1"), "list2: wrong href"); |
|
408 |
|
409 // 2 elm list |
|
410 WebdavNSList *list3 = wsxml_string2nslist(sn->pool, "x:ns1\ny:ns2"); |
|
411 UCX_TEST_ASSERT(list3, "list3 is NULL"); |
|
412 UCX_TEST_ASSERT(list3->namespace, "list3 namespace is NULL"); |
|
413 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"), "list3: wrong prefix"); |
|
414 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: wrong href"); |
|
415 UCX_TEST_ASSERT(list3->next, "list3 elm2 is NULL"); |
|
416 UCX_TEST_ASSERT(list3->next->namespace, "list3 namespace 2 is NULL"); |
|
417 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->prefix, "x"), "list3: elm2 wrong prefix"); |
|
418 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: elm2 wrong href"); |
|
419 |
|
420 // empty prefix |
|
421 WebdavNSList *list4 = wsxml_string2nslist(sn->pool, ":x\ny:ns2"); |
|
422 UCX_TEST_ASSERT(list4, "list4 is NULL"); |
|
423 UCX_TEST_ASSERT(list4->namespace, "list4 namespace is NULL"); |
|
424 UCX_TEST_ASSERT(!list4->namespace->prefix, "list4 elm1 prefix should be NULL"); |
|
425 UCX_TEST_ASSERT(!strcmp((const char*)list3->namespace->href, "ns1"), "list3: wrong href"); |
|
426 |
|
427 |
|
428 UCX_TEST_END; |
|
429 //testutil_destroy_session(sn); |
|
430 } |