/** * parse decimal. */ @Test public void parseDecimal() { Function<Object, BigDecimal> parser = s -> StringOptionUtil.parseDecimal(new StringOption(String.valueOf(s))); assertThat(parser.apply("0"), is(new BigDecimal("0"))); assertThat(parser.apply("1"), is(new BigDecimal("1"))); assertThat(parser.apply("+100"), is(new BigDecimal("100"))); assertThat(parser.apply("-100"), is(new BigDecimal("-100"))); assertThat(parser.apply("+3.14"), is(new BigDecimal("3.14"))); assertThat(parser.apply("-3.14"), is(new BigDecimal("-3.14"))); assertThat(parser.apply(Long.MAX_VALUE), is(new BigDecimal(Long.MAX_VALUE))); assertThat(parser.apply(Long.MIN_VALUE), is(new BigDecimal(Long.MIN_VALUE))); raise(() -> parser.apply("")); raise(() -> parser.apply("Hello, world!")); }