|
18 | 18 |
|
19 | 19 | import static com.google.common.testing.SerializableTester.reserializeAndAssert;
|
20 | 20 | import static com.google.common.truth.Truth.assertThat;
|
| 21 | +import static org.junit.Assert.assertEquals; |
21 | 22 | import static org.junit.Assert.assertNotNull;
|
22 | 23 |
|
23 | 24 | import com.google.common.testing.EqualsTester;
|
@@ -81,27 +82,43 @@ public void ofDate() {
|
81 | 82 | }
|
82 | 83 |
|
83 | 84 | @Test
|
84 |
| - public void ofSqlTimestamp() { |
| 85 | + public void testOf() { |
85 | 86 | String expectedTimestampString = "1970-01-01T00:00:12.345000000Z";
|
86 | 87 | java.sql.Timestamp input = new java.sql.Timestamp(12345);
|
87 | 88 | Timestamp timestamp = Timestamp.of(input);
|
88 |
| - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); |
| 89 | + assertEquals(timestamp.toString(), expectedTimestampString); |
89 | 90 | }
|
90 | 91 |
|
91 | 92 | @Test
|
92 |
| - public void ofSqlTimestampPreEpoch() { |
| 93 | + public void testOf_exactSecond() { |
| 94 | + String expectedTimestampString = "1970-01-01T00:00:12Z"; |
| 95 | + java.sql.Timestamp input = new java.sql.Timestamp(12000); |
| 96 | + Timestamp timestamp = Timestamp.of(input); |
| 97 | + assertEquals(timestamp.toString(), expectedTimestampString); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + public void testOf_preEpoch() { |
93 | 102 | String expectedTimestampString = "1969-12-31T23:59:47.655000000Z";
|
94 | 103 | java.sql.Timestamp input = new java.sql.Timestamp(-12345);
|
95 | 104 | Timestamp timestamp = Timestamp.of(input);
|
96 |
| - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); |
| 105 | + assertEquals(timestamp.toString(), expectedTimestampString); |
97 | 106 | }
|
98 | 107 |
|
99 | 108 | @Test
|
100 |
| - public void ofSqlTimestampOnEpoch() { |
| 109 | + public void testOf_onEpoch() { |
101 | 110 | String expectedTimestampString = "1970-01-01T00:00:00Z";
|
102 | 111 | java.sql.Timestamp input = new java.sql.Timestamp(0);
|
103 | 112 | Timestamp timestamp = Timestamp.of(input);
|
104 |
| - assertThat(timestamp.toString()).isEqualTo(expectedTimestampString); |
| 113 | + assertEquals(timestamp.toString(), expectedTimestampString); |
| 114 | + } |
| 115 | + |
| 116 | + @Test |
| 117 | + public void testOf_preEpochExactSecond() { |
| 118 | + String expectedTimestampString = "1969-12-31T23:59:59Z"; |
| 119 | + java.sql.Timestamp input = new java.sql.Timestamp(-1000); |
| 120 | + Timestamp timestamp = Timestamp.of(input); |
| 121 | + assertEquals(timestamp.toString(), expectedTimestampString); |
105 | 122 | }
|
106 | 123 |
|
107 | 124 | @Test
|
|
0 commit comments