-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the parse and compare hooks
- Loading branch information
1 parent
40364e7
commit 06c8f73
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package de.jplag; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import de.jplag.exceptions.ExitException; | ||
|
||
public class HooksTest extends TestBase { | ||
private static final String ROOT = "NoDuplicate"; | ||
private static final int SUBMISSION_COUNT = 3; | ||
private static final int COMPARISON_COUNT = 3; | ||
|
||
@Test | ||
void testPreParseHook() throws ExitException { | ||
final int[] totalSubmissions = {0}; | ||
runJPlag(ROOT, it -> it.withPreParseHook(submissions -> { | ||
totalSubmissions[0] = submissions.size(); | ||
})); | ||
assertEquals(SUBMISSION_COUNT, totalSubmissions[0]); | ||
} | ||
|
||
@Test | ||
void testParseHook() throws ExitException { | ||
final int[] totalSubmissions = {0}; | ||
runJPlag(ROOT, it -> it.withParseHook(submission -> { | ||
totalSubmissions[0] += 1; | ||
})); | ||
assertEquals(SUBMISSION_COUNT, totalSubmissions[0]); | ||
} | ||
|
||
@Test | ||
void testPreCompareHook() throws ExitException { | ||
final int[] totalComparisons = {0}; | ||
runJPlag(ROOT, it -> it.withPreCompareHook(comparisons -> { | ||
totalComparisons[0] = comparisons.size(); | ||
})); | ||
assertEquals(COMPARISON_COUNT, totalComparisons[0]); | ||
} | ||
|
||
@Test | ||
void testCompareHook() throws ExitException { | ||
final int[] totalComparisons = {0}; | ||
runJPlag(ROOT, it -> it.withCompareHook(comparison -> { | ||
totalComparisons[0] += 1; | ||
})); | ||
assertEquals(COMPARISON_COUNT, totalComparisons[0]); | ||
} | ||
} |