예제 #1
0
  public void testDecodeIntFails() {
    try {
      // One more than maximum value
      int unused = UnsignedInts.decode("0xfffffffff");
      fail();
    } catch (NumberFormatException expected) {
    }

    try {
      int unused = UnsignedInts.decode("-5");
      fail();
    } catch (NumberFormatException expected) {
    }

    try {
      int unused = UnsignedInts.decode("-0x5");
      fail();
    } catch (NumberFormatException expected) {
    }

    try {
      int unused = UnsignedInts.decode("-05");
      fail();
    } catch (NumberFormatException expected) {
    }
  }
예제 #2
0
 public void testDecodeInt() {
   assertEquals(0xffffffff, UnsignedInts.decode("0xffffffff"));
   assertEquals(01234567, UnsignedInts.decode("01234567")); // octal
   assertEquals(0x12345678, UnsignedInts.decode("#12345678"));
   assertEquals(76543210, UnsignedInts.decode("76543210"));
   assertEquals(0x13579135, UnsignedInts.decode("0x13579135"));
   assertEquals(0x13579135, UnsignedInts.decode("0X13579135"));
   assertEquals(0, UnsignedInts.decode("0"));
 }