Fri, 17 Jan 2020 19:08:19 +0100
add tests for some webdav plist util functions
--- a/src/server/test/main.c Fri Jan 17 17:42:10 2020 +0100 +++ b/src/server/test/main.c Fri Jan 17 19:08:19 2020 +0100 @@ -74,6 +74,8 @@ ucx_test_register(suite, test_wsxml_get_required_namespaces); // webdav tests + ucx_test_register(suite, test_webdav_plist_add); + ucx_test_register(suite, test_webdav_plist_size); ucx_test_register(suite, test_propfind_parse); ucx_test_register(suite, test_proppatch_parse); ucx_test_register(suite, test_lock_parse);
--- 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", "/");
--- a/src/server/test/webdav.h Fri Jan 17 17:42:10 2020 +0100 +++ b/src/server/test/webdav.h Fri Jan 17 19:08:19 2020 +0100 @@ -38,6 +38,9 @@ extern "C" { #endif +UCX_TEST(test_webdav_plist_add); +UCX_TEST(test_webdav_plist_size); + UCX_TEST(test_propfind_parse); UCX_TEST(test_proppatch_parse); UCX_TEST(test_lock_parse);