Remove @author tags
[Sone.git] / src / test / java / net / pterodactylus / sone / utils / NumberParsersTest.java
1 package net.pterodactylus.sone.utils;
2
3 import static net.pterodactylus.sone.utils.NumberParsers.parseInt;
4 import static net.pterodactylus.sone.utils.NumberParsers.parseLong;
5 import static org.hamcrest.MatcherAssert.assertThat;
6 import static org.hamcrest.Matchers.is;
7 import static org.hamcrest.Matchers.nullValue;
8
9 import org.junit.Test;
10
11 /**
12  * Unit test for {@link NumberParsers}.
13  */
14 public class NumberParsersTest {
15
16         @Test
17         // yes, this test is for coverage only.
18         public void constructorCanBeCalled() {
19                 new NumberParsers();
20         }
21
22         @Test
23         public void nullIsParsedToDefaultInt() {
24                 assertThat(parseInt(null, 17), is(17));
25         }
26
27         @Test
28         public void notANumberIsParsedToDefaultInt() {
29                 assertThat(parseInt("not a number", 18), is(18));
30         }
31
32         @Test
33         public void intIsCorrectlyParsed() {
34                 assertThat(parseInt("19", 0), is(19));
35         }
36
37         @Test
38         public void valueTooLargeForIntIsParsedToDefault() {
39                 assertThat(parseInt("2147483648", 20), is(20));
40         }
41
42         @Test
43         public void valueTooSmallForIntIsParsedToDefault() {
44                 assertThat(parseInt("-2147483649", 20), is(20));
45         }
46
47         @Test
48         public void nullCanBeDefaultIntValue() {
49                 assertThat(parseInt("not a number", null), nullValue());
50         }
51
52         @Test
53         public void nullIsParsedToDefaultLong() {
54                 assertThat(parseLong(null, 17L), is(17L));
55         }
56
57         @Test
58         public void notANumberIsParsedToDefaultLong() {
59                 assertThat(parseLong("not a number", 18L), is(18L));
60         }
61
62         @Test
63         public void LongIsCorrectlyParsed() {
64                 assertThat(parseLong("19", 0L), is(19L));
65         }
66
67         @Test
68         public void valueTooLargeForLongIsParsedToDefault() {
69                 assertThat(parseLong("9223372036854775808", 20L), is(20L));
70         }
71
72         @Test
73         public void valueTooSmallForLongIsParsedToDefault() {
74                 assertThat(parseLong("-9223372036854775809", 20L), is(20L));
75         }
76
77         @Test
78         public void nullCanBeDefaultLongValue() {
79                 assertThat(parseLong("not a number", null), nullValue());
80         }
81
82 }