Skip to content

Commit b41b21c

Browse files
author
Vladimir Kotal
committed
add tests for equals() that utilize file list
1 parent c8d58df commit b41b21c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/history/HistoryEntryTest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
import org.junit.jupiter.api.BeforeEach;
2727
import org.junit.jupiter.api.Test;
2828

29+
import java.io.File;
30+
import java.nio.file.Paths;
2931
import java.util.Collections;
3032
import java.util.Date;
33+
import java.util.Set;
3134
import java.util.TreeSet;
3235

3336
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -269,4 +272,40 @@ public void testEquals() {
269272
assertNotSame(e, instance);
270273
assertEquals(e, instance);
271274
}
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+
}
272311
}

0 commit comments

Comments
 (0)