-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test cases for OriginalityThresholdArgumentType
- Loading branch information
1 parent
6e33b3d
commit ffbea17
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/test/java/reposense/parser/OriginalityThresholdArgumentTypeTest.java
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,31 @@ | ||
package reposense.parser; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import net.sourceforge.argparse4j.inf.ArgumentParserException; | ||
|
||
public class OriginalityThresholdArgumentTypeTest { | ||
|
||
@Test | ||
public void originalityThresholdArgumentType_convertValidInput_success() throws ArgumentParserException { | ||
Assertions.assertEquals(0, convert("0")); | ||
Assertions.assertEquals(0.0001, convert("0.0001")); | ||
Assertions.assertEquals(0.5, convert("0.5")); | ||
Assertions.assertEquals(0.9999, convert("0.9999")); | ||
Assertions.assertEquals(1, convert("1")); | ||
} | ||
|
||
@Test | ||
public void originalityThresholdArgumentType_convertOutOfBoundInput_throwException() { | ||
Assertions.assertThrowsExactly(ArgumentParserException.class, () -> convert("-10.123")); | ||
Assertions.assertThrowsExactly(ArgumentParserException.class, () -> convert("-0.0001")); | ||
Assertions.assertThrowsExactly(ArgumentParserException.class, () -> convert("1.0001")); | ||
Assertions.assertThrowsExactly(ArgumentParserException.class, () -> convert("10.123")); | ||
} | ||
|
||
private double convert(String input) throws ArgumentParserException { | ||
OriginalityThresholdArgumentType converter = new OriginalityThresholdArgumentType(); | ||
return converter.convert(null, null, input); | ||
} | ||
} |