2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2013 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
23 #include <grub/misc.h>
24 #include <grub/datetime.h>
25 #include <grub/test.h>
28 date_test (grub_int32_t v)
30 struct grub_datetime dt;
37 grub_unixtime2datetime (v, &dt);
39 w = grub_get_weekday (&dt);
41 grub_test_assert (g->tm_sec == dt.second, "time %d bad second: %d vs %d", v,
42 g->tm_sec, dt.second);
43 grub_test_assert (g->tm_min == dt.minute, "time %d bad minute: %d vs %d", v,
44 g->tm_min, dt.minute);
45 grub_test_assert (g->tm_hour == dt.hour, "time %d bad hour: %d vs %d", v,
47 grub_test_assert (g->tm_mday == dt.day, "time %d bad day: %d vs %d", v,
49 grub_test_assert (g->tm_mon + 1 == dt.month, "time %d bad month: %d vs %d", v,
50 g->tm_mon + 1, dt.month);
51 grub_test_assert (g->tm_year + 1900 == dt.year,
52 "time %d bad year: %d vs %d", v,
53 g->tm_year + 1900, dt.year);
54 grub_test_assert (g->tm_wday == w, "time %d bad week day: %d vs %d", v,
61 grub_int32_t tests[] = { -1, 0, +1, -2133156255, GRUB_INT32_MIN,
65 for (i = 0; i < ARRAY_SIZE (tests); i++)
68 for (i = 0; i < 1000000; i++)
70 grub_int32_t x = rand ();
76 GRUB_UNIT_TEST ("date_unit_test", date_test_iter);