| 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 "utils.h" |
29 #include "test.h" |
| |
30 |
| 30 #include <libidav/utils.h> |
31 #include <libidav/utils.h> |
| 31 |
32 |
| 32 CX_TEST(test_util_parse_creationdate) { |
33 UCX_TEST(test_util_parse_creationdate) { |
| 33 CX_TEST_DO { |
34 UCX_TEST_BEGIN; |
| 34 time_t t1 = util_parse_creationdate("2012-11-29T21:35:36Z"); |
35 |
| 35 time_t t2 = util_parse_creationdate("2023-09-17T13:03:00+02:00"); |
36 time_t t1 = util_parse_creationdate("2012-11-29T21:35:36Z"); |
| 36 |
37 time_t t2 = util_parse_creationdate("2023-09-17T13:03:00+02:00"); |
| 37 struct tm *tm = gmtime(&t1); |
38 |
| 38 CX_TEST_ASSERT(tm->tm_year == 112); |
39 struct tm *tm = gmtime(&t1); |
| 39 CX_TEST_ASSERT(tm->tm_mon == 10); |
40 UCX_TEST_ASSERT(tm->tm_year == 112, "t1: wrong year"); |
| 40 CX_TEST_ASSERT(tm->tm_mday == 29); |
41 UCX_TEST_ASSERT(tm->tm_mon == 10, "t1: wrong month"); |
| 41 CX_TEST_ASSERT(tm->tm_hour == 21); |
42 UCX_TEST_ASSERT(tm->tm_mday == 29, "t1: wrong day"); |
| 42 CX_TEST_ASSERT(tm->tm_min == 35); |
43 UCX_TEST_ASSERT(tm->tm_hour == 21, "t1: wrong hour"); |
| 43 CX_TEST_ASSERT(tm->tm_sec == 36); |
44 UCX_TEST_ASSERT(tm->tm_min == 35, "t1: wrong minute"); |
| 44 |
45 UCX_TEST_ASSERT(tm->tm_sec == 36, "t1: wrong second"); |
| 45 tm = gmtime(&t2); |
46 |
| 46 CX_TEST_ASSERT(tm->tm_year == 123); |
47 tm = gmtime(&t2); |
| 47 CX_TEST_ASSERT(tm->tm_mon == 8); |
48 UCX_TEST_ASSERT(tm->tm_year == 123, "t2: wrong year"); |
| 48 CX_TEST_ASSERT(tm->tm_mday == 17); |
49 UCX_TEST_ASSERT(tm->tm_mon == 8, "t2: wrong month"); |
| 49 CX_TEST_ASSERT(tm->tm_hour == 11); |
50 UCX_TEST_ASSERT(tm->tm_mday == 17, "t2: wrong day"); |
| 50 CX_TEST_ASSERT(tm->tm_min == 03); |
51 UCX_TEST_ASSERT(tm->tm_hour == 11, "t2: wrong hour"); |
| 51 CX_TEST_ASSERT(tm->tm_sec == 0); |
52 UCX_TEST_ASSERT(tm->tm_min == 03, "t2: wrong minute"); |
| 52 } |
53 UCX_TEST_ASSERT(tm->tm_sec == 0, "t2: wrong second"); |
| |
54 |
| |
55 UCX_TEST_END; |
| |
56 |
| |
57 |
| 53 } |
58 } |