Skip to content

Commit

Permalink
Add tests for the parse and compare hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
olmokramer committed Sep 15, 2023
1 parent 40364e7 commit 06c8f73
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions core/src/test/java/de/jplag/HooksTest.java
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]);
}
}

0 comments on commit 06c8f73

Please sign in to comment.