test/utils.c

branch
dav-2
changeset 879
255a5ef46400
parent 792
4e4e5bbad164
child 889
42cdbf9bbd49
equal deleted inserted replaced
878:68ea3a0fe66f 879:255a5ef46400
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "test.h" 29 #include "utils.h"
30
31 #include <libidav/utils.h> 30 #include <libidav/utils.h>
32 31
33 UCX_TEST(test_util_parse_creationdate) { 32 CX_TEST(test_util_parse_creationdate) {
34 UCX_TEST_BEGIN; 33 CX_TEST_DO {
35 34 time_t t1 = util_parse_creationdate("2012-11-29T21:35:36Z");
36 time_t t1 = util_parse_creationdate("2012-11-29T21:35:36Z"); 35 time_t t2 = util_parse_creationdate("2023-09-17T13:03:00+02:00");
37 time_t t2 = util_parse_creationdate("2023-09-17T13:03:00+02:00"); 36
38 37 struct tm *tm = gmtime(&t1);
39 struct tm *tm = gmtime(&t1); 38 CX_TEST_ASSERT(tm->tm_year == 112);
40 UCX_TEST_ASSERT(tm->tm_year == 112, "t1: wrong year"); 39 CX_TEST_ASSERT(tm->tm_mon == 10);
41 UCX_TEST_ASSERT(tm->tm_mon == 10, "t1: wrong month"); 40 CX_TEST_ASSERT(tm->tm_mday == 29);
42 UCX_TEST_ASSERT(tm->tm_mday == 29, "t1: wrong day"); 41 CX_TEST_ASSERT(tm->tm_hour == 21);
43 UCX_TEST_ASSERT(tm->tm_hour == 21, "t1: wrong hour"); 42 CX_TEST_ASSERT(tm->tm_min == 35);
44 UCX_TEST_ASSERT(tm->tm_min == 35, "t1: wrong minute"); 43 CX_TEST_ASSERT(tm->tm_sec == 36);
45 UCX_TEST_ASSERT(tm->tm_sec == 36, "t1: wrong second"); 44
46 45 tm = gmtime(&t2);
47 tm = gmtime(&t2); 46 CX_TEST_ASSERT(tm->tm_year == 123);
48 UCX_TEST_ASSERT(tm->tm_year == 123, "t2: wrong year"); 47 CX_TEST_ASSERT(tm->tm_mon == 8);
49 UCX_TEST_ASSERT(tm->tm_mon == 8, "t2: wrong month"); 48 CX_TEST_ASSERT(tm->tm_mday == 17);
50 UCX_TEST_ASSERT(tm->tm_mday == 17, "t2: wrong day"); 49 CX_TEST_ASSERT(tm->tm_hour == 11);
51 UCX_TEST_ASSERT(tm->tm_hour == 11, "t2: wrong hour"); 50 CX_TEST_ASSERT(tm->tm_min == 03);
52 UCX_TEST_ASSERT(tm->tm_min == 03, "t2: wrong minute"); 51 CX_TEST_ASSERT(tm->tm_sec == 0);
53 UCX_TEST_ASSERT(tm->tm_sec == 0, "t2: wrong second"); 52 }
54
55 UCX_TEST_END;
56
57
58 } 53 }

mercurial