1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.commons.compress.utils;
21
22 import static org.junit.jupiter.api.Assertions.assertEquals;
23 import static org.junit.jupiter.api.Assertions.assertThrows;
24
25 import java.io.IOException;
26
27 import org.junit.jupiter.params.ParameterizedTest;
28 import org.junit.jupiter.params.provider.ValueSource;
29
30
31
32
33
34
35 class ParsingUtilsTest {
36
37 @ParameterizedTest
38 @ValueSource(strings = {Integer.MIN_VALUE + "1", "x.x", "9e999", "1.1", "one", Integer.MAX_VALUE + "1"})
39 void testParseIntValueInvalidValues(final String value) {
40 assertThrows(IOException.class, () -> ParsingUtils.parseIntValue(value, 10));
41 }
42
43 @ParameterizedTest
44 @ValueSource(strings = {Integer.MIN_VALUE + "", "-1", "1", "123456", Integer.MAX_VALUE + ""})
45 void testParseIntValueValidValues(final String value) throws Exception {
46 assertEquals(Long.parseLong(value), ParsingUtils.parseIntValue(value, 10));
47 }
48
49 @ParameterizedTest
50 @ValueSource(strings = {Long.MIN_VALUE + "1", "x.x", "9e999", "1.1", "one", Long.MAX_VALUE + "1"})
51 void testParseLongValueInvalidValues(final String value) {
52 assertThrows(IOException.class, () -> ParsingUtils.parseLongValue(value, 10));
53 }
54
55 @ParameterizedTest
56 @ValueSource(strings = {Long.MIN_VALUE + "", "-1", "1", "12345678901234", Long.MAX_VALUE + ""})
57 void testParseLongValueValidValues(final String value) throws Exception {
58 assertEquals(Long.parseLong(value), ParsingUtils.parseLongValue(value, 10));
59 }
60
61 }