diff -r 3c23855f7b46 -r c0afce708b1d src/server/test/webdav.c --- a/src/server/test/webdav.c Fri Jan 17 17:42:10 2020 +0100 +++ b/src/server/test/webdav.c Fri Jan 17 19:08:19 2020 +0100 @@ -216,6 +216,77 @@ response); } + +UCX_TEST(test_webdav_plist_add) { + Session *sn = testutil_session(); + + UCX_TEST_BEGIN; + + WebdavPList *begin = NULL; + WebdavPList *end = NULL; + + WebdavProperty p1, p2, p3; + ZERO(&p1, sizeof(WebdavProperty)); + ZERO(&p2, sizeof(WebdavProperty)); + ZERO(&p3, sizeof(WebdavProperty)); + int r; + + r = webdav_plist_add(sn->pool, &begin, &end, &p1); + + UCX_TEST_ASSERT(r == 0, "add 1 failed"); + UCX_TEST_ASSERT(begin && end, "ptrs are NULL"); + UCX_TEST_ASSERT(begin == end, "begin != end"); + UCX_TEST_ASSERT(begin->prev == NULL, "begin->prev not NULL"); + UCX_TEST_ASSERT(begin->next == NULL, "begin->next not NULL"); + + r = webdav_plist_add(sn->pool, &begin, &end, &p2); + + UCX_TEST_ASSERT(r == 0, "add 2 failed"); + UCX_TEST_ASSERT(begin && end, "add2: ptrs are NULL"); + UCX_TEST_ASSERT(begin->next, "begin->next is NULL"); + UCX_TEST_ASSERT(begin->next == end, "begin->next != end"); + UCX_TEST_ASSERT(end->prev = begin, "end->prev != begin"); + UCX_TEST_ASSERT(begin->prev == NULL, "add2: begin->prev not NULL"); + UCX_TEST_ASSERT(end->next == NULL, "add2: end->next not NULL"); + + r = webdav_plist_add(sn->pool, &begin, &end, &p3); + + UCX_TEST_ASSERT(r == 0, "add 3 failed"); + UCX_TEST_ASSERT(begin && end, "add3: ptrs are NULL"); + UCX_TEST_ASSERT(begin->next == end->prev, "begin->next != end->prev"); + + UCX_TEST_END; + + testutil_destroy_session(sn); +} + +UCX_TEST(test_webdav_plist_size) { + Session *sn = testutil_session(); + + UCX_TEST_BEGIN; + + WebdavPList *begin = NULL; + WebdavPList *end = NULL; + + WebdavProperty p1, p2, p3; + ZERO(&p1, sizeof(WebdavProperty)); + ZERO(&p2, sizeof(WebdavProperty)); + ZERO(&p3, sizeof(WebdavProperty)); + int r; + + UCX_TEST_ASSERT(webdav_plist_size(begin) == 0, "size != 0"); + r = webdav_plist_add(sn->pool, &begin, &end, &p1); + UCX_TEST_ASSERT(webdav_plist_size(begin) == 1, "size != 1"); + r = webdav_plist_add(sn->pool, &begin, &end, &p2); + UCX_TEST_ASSERT(webdav_plist_size(begin) == 2, "size != 2"); + r = webdav_plist_add(sn->pool, &begin, &end, &p3); + UCX_TEST_ASSERT(webdav_plist_size(begin) == 3, "size != 3"); + + UCX_TEST_END; + + testutil_destroy_session(sn); +} + UCX_TEST(test_propfind_parse) { Session *sn = testutil_session(); Request *rq = testutil_request(sn->pool, "PROPFIND", "/");