コード例 #1
0
 @Test
 public void testParseHexOrDefaultOk() throws Exception {
   long i = 0x12;
   String s = "0x" + Long.toHexString(i);
   int def = 14;
   assertEquals(i, ParseLong.parseHexOrDefault(s, def));
 }
コード例 #2
0
 @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());
 }
コード例 #3
0
 @Test
 public void testParseHexPrefixEquals() throws Exception {
   long i = 123456;
   String s = Long.toHexString(i);
   String s1 = "0x" + s;
   String s2 = "0X" + s;
   //  Transitive property means we only have to test twice
   assertEquals(ParseLong.parseHex(s), ParseLong.parseHex(s1));
   assertEquals(ParseLong.parseHex(s1), ParseLong.parseHex(s2));
 }
コード例 #4
0
 private String getUniqueId() {
   return Long.toHexString(Double.doubleToLongBits(Math.random()));
 }
コード例 #5
0
 //  Test dec/hex hex trimming
 @Test
 public void testParse_HexTrim() throws Exception {
   long i = 0x123ABC;
   String s = WHITESPACE + "0x" + Long.toHexString(i) + WHITESPACE;
   assertEquals(i, ParseLong.parse(s));
 }
コード例 #6
0
 //  Test dec/hex picking
 @Test
 public void testParse_Hex() throws Exception {
   long i = 0x123ABC;
   String s = "0x" + Long.toHexString(i);
   assertEquals(i, ParseLong.parse(s));
 }
コード例 #7
0
 //  Technically this is the same as MaxUnsigned
 @Test
 public void testParseHexMinSigned() throws Exception {
   long i = Long.MIN_VALUE;
   String s = "0x" + Long.toHexString(i);
   assertEquals(i, ParseLong.parseHex(s));
 }
コード例 #8
0
 @Test
 public void testParseHex() throws Exception {
   long i = 123456;
   String s = Long.toHexString(i);
   assertEquals(i, ParseLong.parseHex(s));
 }