|
1 | 1 | local gigasecond = require('gigasecond') |
2 | 2 |
|
3 | 3 | describe('gigasecond', function() |
4 | | - it('test 1', function() |
5 | | - local actual = gigasecond.anniversary(os.time({ year = 2011, month = 3, day = 25, hour = 0, min = 0, sec = 0 })) |
6 | | - local expectedDate = os.date('%x', os.time({ year = 2042, month = 12, day = 1, hour = 0, min = 0, sec = 0 })) |
7 | | - assert.are.equals(expectedDate, actual) |
| 4 | + it('date only specification of time', function() |
| 5 | + local moment_a = os.time({ year = 2011, month = 4, day = 25, hour = 0, min = 0, sec = 0 }) |
| 6 | + local moment_b = os.time({ year = 2043, month = 1, day = 1, hour = 1, min = 46, sec = 40 }) |
| 7 | + local actual = gigasecond.anniversary(moment_a) |
| 8 | + local expected = os.date('!%x', moment_b) |
| 9 | + assert.are.equals(expected, actual) |
8 | 10 | end) |
9 | 11 |
|
10 | | - it('test 2', function() |
11 | | - local actual = gigasecond.anniversary(os.time({ year = 1977, month = 5, day = 13, hour = 0, min = 0, sec = 0 })) |
12 | | - local expectedDate = os.date('%x', os.time({ year = 2009, month = 1, day = 19 })) |
13 | | - assert.are.equals(expectedDate, actual) |
| 12 | + it('second test for date only specification of time', function() |
| 13 | + local moment_a = os.time({ year = 1977, month = 6, day = 13, hour = 0, min = 0, sec = 0 }) |
| 14 | + local moment_b = os.time({ year = 2009, month = 2, day = 19, hour = 1, min = 46, sec = 40 }) |
| 15 | + local actual = gigasecond.anniversary(moment_a) |
| 16 | + local expected = os.date('!%x', moment_b) |
| 17 | + assert.are.equals(expected, actual) |
14 | 18 | end) |
15 | 19 |
|
16 | | - it('test 3', function() |
17 | | - local actual = gigasecond.anniversary(os.time({ year = 1999, month = 7, day = 19 })) |
18 | | - local expectedDate = os.date('%x', os.time({ year = 2031, month = 3, day = 27 })) |
19 | | - assert.are.equals(expectedDate, actual) |
| 20 | + it('third test for date only specification of time', function() |
| 21 | + local moment_a = os.time({ year = 1959, month = 7, day = 19, hour = 0, min = 0, sec = 0 }) |
| 22 | + local moment_b = os.time({ year = 1991, month = 3, day = 27, hour = 1, min = 46, sec = 40 }) |
| 23 | + local actual = gigasecond.anniversary(moment_a) |
| 24 | + local expected = os.date('!%x', moment_b) |
| 25 | + assert.are.equals(expected, actual) |
20 | 26 | end) |
21 | 27 |
|
22 | | - it('test 4', function() |
23 | | - local actual = gigasecond.anniversary(os.time({ year = 1993, month = 8, day = 17 })) |
24 | | - local expectedDate = os.date('%x', os.time({ year = 2025, month = 4, day = 25 })) |
25 | | - assert.are.equals(expectedDate, actual) |
| 28 | + it('full time specified', function() |
| 29 | + local moment_a = os.time({ year = 2015, month = 1, day = 24, hour = 22, min = 0, sec = 0 }) |
| 30 | + local moment_b = os.time({ year = 2046, month = 10, day = 2, hour = 23, min = 46, sec = 40 }) |
| 31 | + local actual = gigasecond.anniversary(moment_a) |
| 32 | + local expected = os.date('!%x', moment_b) |
| 33 | + assert.are.equals(expected, actual) |
| 34 | + end) |
| 35 | + |
| 36 | + it('full time with day roll-over', function() |
| 37 | + local moment_a = os.time({ year = 2015, month = 1, day = 24, hour = 23, min = 59, sec = 59 }) |
| 38 | + local moment_b = os.time({ year = 2046, month = 10, day = 3, hour = 1, min = 46, sec = 39 }) |
| 39 | + local actual = gigasecond.anniversary(moment_a) |
| 40 | + local expected = os.date('!%x', moment_b) |
| 41 | + assert.are.equals(expected, actual) |
26 | 42 | end) |
27 | 43 | end) |
0 commit comments