MCPcopy Create free account
hub / github.com/MenoData/Time4J / DateComparisonTest

Class DateComparisonTest

base/src/test/java/net/time4j/DateComparisonTest.java:14–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14@RunWith(JUnit4.class)
15public class DateComparisonTest {
16
17 @Test
18 public void equalsMethod() {
19 PlainDate d1 = PlainDate.of(1, 1);
20 Object d2 = PlainDate.of(1, 1, 1);
21 Object d3 = null;
22 Object d4 = PlainDate.of(2014, 1, 1);
23 Object d5 =
24 new GregorianDate() {
25 @Override
26 public int getYear() {
27 return 1;
28 }
29 @Override
30 public int getMonth() {
31 return 1;
32 }
33 @Override
34 public int getDayOfMonth() {
35 return 1;
36 }
37 };
38 assertThat(d1.equals(d2), is(true));
39 assertThat(d1.equals(d3), is(false));
40 assertThat(d1.equals(d4), is(false));
41 assertThat(d1.equals(d5), is(false));
42 }
43
44 @Test
45 public void hashCodeMethod() {
46 PlainDate d1 = PlainDate.of(1, 1);
47 Object d2 = PlainDate.of(1, 1, 1);
48 Object d3 = PlainDate.of(2014, 1, 1);
49 Object d4 =
50 new GregorianDate() {
51 @Override
52 public int getYear() {
53 return 1;
54 }
55 @Override
56 public int getMonth() {
57 return 1;
58 }
59 @Override
60 public int getDayOfMonth() {
61 return 1;
62 }
63 };
64 assertThat(d1.hashCode() == d2.hashCode(), is(true));
65 assertThat(d1.hashCode() == d3.hashCode(), is(false));
66 assertThat(d1.hashCode() == d4.hashCode(), is(false));
67 }
68
69 @Test
70 public void isBefore() {
71 assertThat(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected