test/utils.c

Sat, 20 Apr 2024 12:50:38 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 20 Apr 2024 12:50:38 +0200
changeset 814
0ce45bdc48bc
parent 792
4e4e5bbad164
permissions
-rw-r--r--

remove disabled realloc debug code from libxattr

/*
 * 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 "test.h"

#include <libidav/utils.h>

UCX_TEST(test_util_parse_creationdate) {
    UCX_TEST_BEGIN;
    
    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);
    UCX_TEST_ASSERT(tm->tm_year == 112, "t1: wrong year");
    UCX_TEST_ASSERT(tm->tm_mon == 10, "t1: wrong month");
    UCX_TEST_ASSERT(tm->tm_mday == 29, "t1: wrong day");
    UCX_TEST_ASSERT(tm->tm_hour == 21, "t1: wrong hour");
    UCX_TEST_ASSERT(tm->tm_min == 35, "t1: wrong minute");
    UCX_TEST_ASSERT(tm->tm_sec == 36, "t1: wrong second");
    
    tm = gmtime(&t2);
    UCX_TEST_ASSERT(tm->tm_year == 123, "t2: wrong year");
    UCX_TEST_ASSERT(tm->tm_mon == 8, "t2: wrong month");
    UCX_TEST_ASSERT(tm->tm_mday == 17, "t2: wrong day");
    UCX_TEST_ASSERT(tm->tm_hour == 11, "t2: wrong hour");
    UCX_TEST_ASSERT(tm->tm_min == 03, "t2: wrong minute");
    UCX_TEST_ASSERT(tm->tm_sec == 0, "t2: wrong second");
    
    UCX_TEST_END;
    
    
}

mercurial