451 |
451 |
452 UCX_TEST_END; |
452 UCX_TEST_END; |
453 testutil_destroy_session(sn); |
453 testutil_destroy_session(sn); |
454 } |
454 } |
455 |
455 |
|
456 UCX_TEST(test_webdav_plist_iterator_remove_current) { |
|
457 Session *sn; |
|
458 Request *rq; |
|
459 WebdavPropfindRequest *propfind; |
|
460 |
|
461 UCX_TEST_BEGIN; |
|
462 UCX_TEST_ASSERT(!test_init(&sn, &rq, &propfind, TEST_PROPFIND1), "init failed"); |
|
463 |
|
464 WebdavPList *properties1 = webdav_plist_clone(sn->pool, propfind->properties); |
|
465 WebdavPList *properties2 = webdav_plist_clone(sn->pool, propfind->properties); |
|
466 WebdavPList *properties3 = webdav_plist_clone(sn->pool, propfind->properties); |
|
467 WebdavPList *properties4 = webdav_plist_clone(sn->pool, propfind->properties); |
|
468 |
|
469 WebdavPListIterator i; |
|
470 WebdavPList *cur; |
|
471 |
|
472 // test removal of first element |
|
473 i = webdav_plist_iterator(&properties1); |
|
474 while(webdav_plist_iterator_next(&i, &cur)) { |
|
475 if(i.index == 0) { |
|
476 webdav_plist_iterator_remove_current(&i); |
|
477 } |
|
478 } |
|
479 |
|
480 UCX_TEST_ASSERT(!properties1->prev, "test1: prev not cleared"); |
|
481 UCX_TEST_ASSERT(!strcmp(properties1->property->name, "getcontentlength"), "test1: wrong property"); |
|
482 UCX_TEST_ASSERT(!strcmp(properties1->next->property->name, "getcontenttype"), "test1: wrong property 2"); |
|
483 UCX_TEST_ASSERT(properties1->next->prev == properties1, "test1: wrong link"); |
|
484 |
|
485 // test removal of second element |
|
486 i = webdav_plist_iterator(&properties2); |
|
487 while(webdav_plist_iterator_next(&i, &cur)) { |
|
488 if(i.index == 1) { |
|
489 webdav_plist_iterator_remove_current(&i); |
|
490 } |
|
491 } |
|
492 |
|
493 UCX_TEST_ASSERT(!strcmp(properties2->next->property->name, "getcontenttype"), "test2: wrong property"); |
|
494 UCX_TEST_ASSERT(properties2->next->prev == properties2, "test2: wrong link"); |
|
495 UCX_TEST_ASSERT(webdav_plist_size(properties2) == 5, "test2: wrong size"); |
|
496 |
|
497 // remove last element |
|
498 i = webdav_plist_iterator(&properties3); |
|
499 while(webdav_plist_iterator_next(&i, &cur)) { |
|
500 if(i.index == 5) { |
|
501 webdav_plist_iterator_remove_current(&i); |
|
502 } |
|
503 } |
|
504 |
|
505 UCX_TEST_ASSERT(webdav_plist_size(properties3) == 5, "test3: wrong size"); |
|
506 UCX_TEST_ASSERT(!strcmp(properties3->next->next->next->next->property->name, "resourcetype"), "test2: wrong property"); |
|
507 |
|
508 // remove all elements |
|
509 i = webdav_plist_iterator(&properties4); |
|
510 while(webdav_plist_iterator_next(&i, &cur)) { |
|
511 webdav_plist_iterator_remove_current(&i); |
|
512 switch(i.index) { |
|
513 case 0: { |
|
514 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontentlength"), "test4: wrong property 2"); |
|
515 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (0)"); |
|
516 break; |
|
517 } |
|
518 case 1: { |
|
519 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getcontenttype"), "test4: wrong property 3"); |
|
520 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (1)"); |
|
521 break; |
|
522 } |
|
523 case 2: { |
|
524 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getlastmodified"), "test4: wrong property 4"); |
|
525 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (2)"); |
|
526 break; |
|
527 } |
|
528 case 3: { |
|
529 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "resourcetype"), "test4: wrong property 5"); |
|
530 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (3)"); |
|
531 break; |
|
532 } |
|
533 case 4: { |
|
534 UCX_TEST_ASSERT(!strcmp(properties4->property->name, "getetag"), "test4: wrong property 6"); |
|
535 UCX_TEST_ASSERT(properties4->prev == NULL, "test4: prev not NULL (4)"); |
|
536 break; |
|
537 } |
|
538 default: { |
|
539 UCX_TEST_ASSERT(i.index <= 5, "fail"); |
|
540 } |
|
541 } |
|
542 } |
|
543 |
|
544 UCX_TEST_ASSERT(properties4 == NULL, "test4: list not NULL"); |
|
545 |
|
546 UCX_TEST_END; |
|
547 testutil_destroy_session(sn); |
|
548 } |
|
549 |
456 UCX_TEST(test_msresponse_addproperty) { |
550 UCX_TEST(test_msresponse_addproperty) { |
457 Session *sn = testutil_session(); |
551 Session *sn = testutil_session(); |
458 Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
552 Request *rq = testutil_request(sn->pool, "PROPFIND", "/"); |
459 Multistatus *ms = multistatus_response(sn, rq); |
553 Multistatus *ms = multistatus_response(sn, rq); |
460 MSResponse *r; |
554 MSResponse *r; |