/** * parse long. */ @Test public void parseLong() { Function<Object, Long> parser = s -> StringOptionUtil.parseLong(new StringOption(String.valueOf(s))); assertThat(parser.apply("0"), is(0L)); assertThat(parser.apply("1"), is(1L)); assertThat(parser.apply("+100"), is(+100L)); assertThat(parser.apply("-100"), is(-100L)); assertThat(parser.apply(Integer.MAX_VALUE), is((long) Integer.MAX_VALUE)); assertThat(parser.apply(Integer.MIN_VALUE), is((long) Integer.MIN_VALUE)); assertThat(parser.apply(Long.MAX_VALUE), is(Long.MAX_VALUE)); assertThat(parser.apply(Long.MIN_VALUE), is(Long.MIN_VALUE)); raise(() -> parser.apply("")); raise(() -> parser.apply("Hello, world!")); raise(() -> parser.apply(BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.ONE))); raise(() -> parser.apply(BigInteger.valueOf(Long.MIN_VALUE).subtract(BigInteger.ONE))); }