test/utils.c

Mon, 08 Sep 2025 12:10:13 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 08 Sep 2025 12:10:13 +0200
branch
dav-2
changeset 882
86e61b4ef708
parent 879
255a5ef46400
child 889
42cdbf9bbd49
permissions
-rw-r--r--

add dav_resource_path_key

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2023 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include "utils.h"
#include <libidav/utils.h>

CX_TEST(test_util_parse_creationdate) {
    CX_TEST_DO {
        time_t t1 = util_parse_creationdate("2012-11-29T21:35:36Z");
        time_t t2 = util_parse_creationdate("2023-09-17T13:03:00+02:00");

        struct tm *tm = gmtime(&t1);
        CX_TEST_ASSERT(tm->tm_year == 112);
        CX_TEST_ASSERT(tm->tm_mon == 10);
        CX_TEST_ASSERT(tm->tm_mday == 29);
        CX_TEST_ASSERT(tm->tm_hour == 21);
        CX_TEST_ASSERT(tm->tm_min == 35);
        CX_TEST_ASSERT(tm->tm_sec == 36);

        tm = gmtime(&t2);
        CX_TEST_ASSERT(tm->tm_year == 123);
        CX_TEST_ASSERT(tm->tm_mon == 8);
        CX_TEST_ASSERT(tm->tm_mday == 17);
        CX_TEST_ASSERT(tm->tm_hour == 11);
        CX_TEST_ASSERT(tm->tm_min == 03);
        CX_TEST_ASSERT(tm->tm_sec == 0);
    }  
}

mercurial