1/* $NetBSD: humandate.c,v 1.2 2020/05/25 20:47:36 christos Exp $ */ 2 3#include "config.h" 4 5#include "ntp_calendar.h" 6#include "ntp_stdlib.h" 7 8#include "unity.h" 9 10void setUp(void); 11void test_RegularTime(void); 12void test_CurrentTime(void); 13 14 15void 16setUp(void) 17{ 18 init_lib(); 19 20 return; 21} 22 23 24void 25test_RegularTime(void) 26{ 27 time_t sample = 1276601278; 28 char expected[15]; 29 struct tm* tm; 30 31 tm = localtime(&sample); 32 TEST_ASSERT_TRUE(tm != NULL); 33 34 snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); 35 36 TEST_ASSERT_EQUAL_STRING(expected, humantime(sample)); 37 38 return; 39} 40 41void 42test_CurrentTime(void) 43{ 44 time_t sample; 45 char expected[15]; 46 struct tm* tm; 47 48 time(&sample); 49 50 tm = localtime(&sample); 51 TEST_ASSERT_TRUE(tm != NULL); 52 53 snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); 54 55 TEST_ASSERT_EQUAL_STRING(expected, humantime(sample)); 56 57 return; 58} 59