MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test

Function test

code/other/dates.test.cpp:1–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1void test() {
2 /*
3 * Field testing:
4 * - UVa 11356
5 * - UVa 12019
6 * - UVa 893 (had to use long long)
7 * - Kattis booking
8 **/
9
10 int y, m, d;
11 assert_equal(2451545, dateToInt(2000, 1, 1));
12 intToDate(2451545, y, m, d);
13 assert_equal(2000, y);
14 assert_equal(1, m);
15 assert_equal(1, d);
16
17 for (int i = 1; i <= 31; i++) assert_equal((6 + i - 1) % 7, dateToInt(2012, 1, i) % 7);
18 for (int i = 1; i <= 29; i++) assert_equal((2 + i - 1) % 7, dateToInt(2012, 2, i) % 7);
19
20 for (int i = 1; i <= 31; i++) assert_equal((6 + i - 1) % 7, dateToInt(2908, 1, i) % 7);
21 for (int i = 1; i <= 29; i++) assert_equal((2 + i - 1) % 7, dateToInt(2908, 2, i) % 7);
22
23 for (int i = 1; i <= 30; i++) assert_equal((1 + i - 1) % 7, dateToInt(2320, 6, i) % 7);
24 for (int i = 1; i <= 31; i++) assert_equal((2 + i - 1) % 7, dateToInt(2320, 12, i) % 7);
25
26 intToDate(dateToInt(2320, 1, 1) + 4*7 + 9, y, m, d);
27 assert_equal(2320, y);
28 assert_equal(2, m);
29 assert_equal(7, d);
30
31 intToDate(dateToInt(2320, 1, 1) + 4*7 + 9 + 3*7 + 2, y, m, d);
32 assert_equal(2320, y);
33 assert_equal(3, m);
34 assert_equal(1, d);
35}
36// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 3

dateToIntFunction · 0.85
intToDateFunction · 0.85
assert_equalFunction · 0.50

Tested by

no test coverage detected