Size { public static long parseSize(String humanSize) { return parseAndConvertToBytes(humanSize); } private  Size(); static String toHumanSize(long sizeInBytes); static long parseSize(String humanSize); static long parseSizeToMegabytes(String humanSize);  }
@Test public void testParseToByte() { Assert.assertEquals(Size.parseSize("1 kB"), 1024); Assert.assertEquals(Size.parseSize("1000B"), 1000); Assert.assertEquals(Size.parseSize("1000"), 1000); Assert.assertEquals(Size.parseSize("1 MB"), 1024 * 1024); Assert.assertEquals(Size.parseSize("5 mb"), 5 * 1024 * 1024); Assert.assertEquals(Size.parseSize("9.8M"), Float.valueOf(9.8f * 1024 * 1024).longValue()); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testParseErrorInvalidSuffix() { Size.parseSize("1 xx"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testParseErrorInvalidNumber() { Size.parseSize("1.x kB"); }