|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+import org.junit.Test;
|
|
|
2
|
+
|
|
|
3
|
+import java.time.LocalDate;
|
|
|
4
|
+import java.time.LocalDateTime;
|
|
|
5
|
+import java.time.Month;
|
|
|
6
|
+
|
|
|
7
|
+import static org.junit.Assert.assertEquals;
|
|
|
8
|
+
|
|
|
9
|
+public class GigasecondTest {
|
|
|
10
|
+
|
|
|
11
|
+ @Test
|
|
|
12
|
+ public void modernTime() {
|
|
|
13
|
+ Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25));
|
|
|
14
|
+
|
|
|
15
|
+ assertEquals(gigaSecond.Date(), LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40));
|
|
|
16
|
+ }
|
|
|
17
|
+
|
|
|
18
|
+ @Test
|
|
|
19
|
+ public void afterEpochTime() {
|
|
|
20
|
+ Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13));
|
|
|
21
|
+
|
|
|
22
|
+ assertEquals(gigaSecond.Date(), LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40));
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ @Test
|
|
|
26
|
+ public void beforeEpochTime() {
|
|
|
27
|
+ Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19));
|
|
|
28
|
+
|
|
|
29
|
+ assertEquals(gigaSecond.Date(), LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40));
|
|
|
30
|
+ }
|
|
|
31
|
+
|
|
|
32
|
+ @Test
|
|
|
33
|
+ public void withFullTimeSpecified() {
|
|
|
34
|
+ Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0));
|
|
|
35
|
+
|
|
|
36
|
+ assertEquals(gigaSecond.Date(), LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40));
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+ @Test
|
|
|
40
|
+ public void withFullTimeSpecifiedAndDayRollover() {
|
|
|
41
|
+ Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59));
|
|
|
42
|
+
|
|
|
43
|
+ assertEquals(gigaSecond.Date(), LocalDateTime.of(2046, Month.OCTOBER, 3, 1, 46, 39));
|
|
|
44
|
+ }
|
|
|
45
|
+}
|