示例#1
0
 @Override
 public void set(OptionalLong optional) {
   if (optional != null && optional.isPresent()) {
     wrapper.set(optional.getAsLong());
   } else {
     wrapper.set(null);
   }
 }
 @Test
 public void testParseHexOptionalOk() throws Exception {
   long i = 0x14;
   String s = Long.toHexString(i);
   OptionalLong ret = ParseLong.parseHexOptional(s);
   assertTrue(ret.isPresent());
   assertEquals(i, ret.getAsLong());
 }
 @Test
 public void testParseHexOptionalNull() throws Exception {
   OptionalLong ret = ParseLong.parseHexOptional(null);
   assertFalse(ret.isPresent());
 }
 @Test
 public void testParseHexOptionalFail() throws Exception {
   String s = "astg2148465klkast12hkls";
   OptionalLong ret = ParseLong.parseHexOptional(s);
   assertFalse(ret.isPresent());
 }
 @Test
 public void testParseOptionalHexFail() throws Exception {
   String s = "0x12akjhsdr?";
   OptionalLong ret = ParseLong.parseOptional(s);
   assertFalse(ret.isPresent());
 }