@Test public void testValid() { CssDimension dim23 = CssDimension.valueOf("23"); assertEquals(23, dim23.value); CssDimension dim23px = CssDimension.valueOf("23px"); assertEquals(23, dim23px.value); CssDimension negative = CssDimension.valueOf("-1"); assertEquals(-1, negative.value); }
@Test public void testDefaultString() { assertEquals("0px", CssDimension.ZERO.toDefaultString()); assertEquals("23px", CssDimension.valueOf("23").toDefaultString()); }
@Test public void testZero() { assertSame(CssDimension.ZERO, CssDimension.valueOf("0")); assertSame(CssDimension.ZERO, CssDimension.valueOf("0px")); assertEquals(0, CssDimension.ZERO.value); }
@Test(expected = IllegalArgumentException.class) public void testValueOf_unsupportedUnit() { CssDimension.valueOf("23em"); }
@Test(expected = IllegalArgumentException.class) public void testValueOf_startWithSpace() { CssDimension.valueOf(" 23px"); }
@Test(expected = IllegalArgumentException.class) public void testValueOf_emptyString() { CssDimension.valueOf(""); }
@Test(expected = NullPointerException.class) public void testValueOf_nullArgument() { CssDimension.valueOf(null); }