Revize 905f8ab5
Přidáno uživatelem Petr Urban před téměř 3 roky(ů)
src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveFloatTest.java | ||
---|---|---|
1 | 1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.model.types; |
2 | 2 |
|
3 |
import org.junit.jupiter.api.Test; |
|
4 |
|
|
3 | 5 |
import static org.junit.jupiter.api.Assertions.*; |
4 | 6 |
|
5 | 7 |
class PositiveFloatTest { |
6 | 8 |
|
9 |
|
|
10 |
@Test |
|
11 |
void testReturnValuesOutOfLimit() { |
|
12 |
// negative value |
|
13 |
float lessThanZero = -1f; |
|
14 |
Exception exception = assertThrows(NumberFormatException.class, () -> new PositiveFloat(lessThanZero)); |
|
15 |
String expectedMessage = "Positive integer should be between 0 and infinity"; |
|
16 |
String actualMessage = exception.getMessage(); |
|
17 |
assertTrue(actualMessage.equals(expectedMessage)); |
|
18 |
} |
|
19 |
|
|
20 |
@Test |
|
21 |
void testParserWithWrongInput() { |
|
22 |
String badValue = "a5f"; |
|
23 |
assertThrows(NumberFormatException.class, (() -> PositiveFloat.parsePositiveFloat(badValue))); |
|
24 |
} |
|
25 |
|
|
7 | 26 |
} |
src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveIntegerTest.java | ||
---|---|---|
1 | 1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.model.types; |
2 | 2 |
|
3 |
import org.junit.jupiter.api.Test; |
|
4 |
|
|
3 | 5 |
import static org.junit.jupiter.api.Assertions.*; |
4 | 6 |
|
5 | 7 |
class PositiveIntegerTest { |
6 | 8 |
|
9 |
@Test |
|
10 |
void testReturnValuesOutOfLimit() { |
|
11 |
// negative value |
|
12 |
int lessThanZero = -1; |
|
13 |
Exception exception = assertThrows(NumberFormatException.class, () -> new PositiveInteger(lessThanZero)); |
|
14 |
String expectedMessage = "Positive integer should be between 0 and infinity"; |
|
15 |
String actualMessage = exception.getMessage(); |
|
16 |
assertTrue(actualMessage.equals(expectedMessage)); |
|
17 |
} |
|
18 |
|
|
19 |
@Test |
|
20 |
void testParserWithWrongInput() { |
|
21 |
String badValue = "a5"; |
|
22 |
assertThrows(NumberFormatException.class, (() -> PositiveInteger.parsePositiveInteger(badValue))); |
|
23 |
} |
|
24 |
|
|
7 | 25 |
} |
Také k dispozici: Unified diff
#10 created new possible unit tests