|
26 | 26 | import org.junit.jupiter.api.BeforeEach;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
28 | 28 |
|
| 29 | +import java.io.File; |
| 30 | +import java.nio.file.Paths; |
29 | 31 | import java.util.Collections;
|
30 | 32 | import java.util.Date;
|
| 33 | +import java.util.Set; |
31 | 34 | import java.util.TreeSet;
|
32 | 35 |
|
33 | 36 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
@@ -269,4 +272,40 @@ public void testEquals() {
|
269 | 272 | assertNotSame(e, instance);
|
270 | 273 | assertEquals(e, instance);
|
271 | 274 | }
|
| 275 | + |
| 276 | + @Test |
| 277 | + public void testEqualsWithFilesInstance() { |
| 278 | + HistoryEntry e = new HistoryEntry(historyRevision, historyDate, |
| 279 | + historyAuthor, null, historyMessage, true, |
| 280 | + Set.of(File.separator + Paths.get("foo", "main.o"), |
| 281 | + File.separator + Paths.get("foo", "testsprog"))); |
| 282 | + assertNotSame(e, instance); |
| 283 | + assertNotEquals(e, instance); |
| 284 | + } |
| 285 | + |
| 286 | + @Test |
| 287 | + public void testEqualsWithFilesPositive() { |
| 288 | + Set<String> files = Set.of(File.separator + Paths.get("foo", "main.o"), |
| 289 | + File.separator + Paths.get("foo", "testsprog")); |
| 290 | + HistoryEntry e1 = new HistoryEntry(historyRevision, historyDate, |
| 291 | + historyAuthor, null, historyMessage, true, files); |
| 292 | + HistoryEntry e2 = new HistoryEntry(historyRevision, historyDate, |
| 293 | + historyAuthor, null, historyMessage, true, files); |
| 294 | + assertNotSame(e1, e2); |
| 295 | + assertEquals(e1, e2); |
| 296 | + } |
| 297 | + |
| 298 | + @Test |
| 299 | + public void testEqualsWithFilesNegative() { |
| 300 | + String file1 = File.separator + Paths.get("foo", "main.o"); |
| 301 | + String file2 = File.separator + Paths.get("foo", "testsprog"); |
| 302 | + HistoryEntry e1 = new HistoryEntry(historyRevision, historyDate, |
| 303 | + historyAuthor, null, historyMessage, true, |
| 304 | + Set.of(file1, file2)); |
| 305 | + HistoryEntry e2 = new HistoryEntry(historyRevision, historyDate, |
| 306 | + historyAuthor, null, historyMessage, true, |
| 307 | + Set.of(file1, file2 + "X")); |
| 308 | + assertNotSame(e1, e2); |
| 309 | + assertNotEquals(e1, e2); |
| 310 | + } |
272 | 311 | }
|
0 commit comments