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