30313233343536
assertEquals( 10, pixel ); } @Test( expected = IllegalArgumentException.class ) public void testCalculatesPercentageFailsWithNegativePercent() { UnitUtil.percentageToPixel( new Percentage( BigDecimal.TEN ), -100 ); }
52535455565758
UnitUtil.emToPixel( new Em( BigDecimal.TEN ), -10 ); } @Test( expected = IllegalArgumentException.class ) public void testCalculatesEmFailsWithWrongUnit() { UnitUtil.emToPixel( new Percentage( BigDecimal.TEN ), 10 ); }
171172173174175176177
* </p> * * @param value the percentage value to use. Must be >= 0. */ public static Unit percent( double value ) { return new Percentage( BigDecimal.valueOf( value ) ); }