@Test public void testParseHexOrDefaultOk() throws Exception { long i = 0x12; String s = "0x" + Long.toHexString(i); int def = 14; assertEquals(i, ParseLong.parseHexOrDefault(s, def)); }
@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 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)); }
private String getUniqueId() { return Long.toHexString(Double.doubleToLongBits(Math.random())); }
// 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)); }
// 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)); }
// 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)); }
@Test public void testParseHex() throws Exception { long i = 123456; String s = Long.toHexString(i); assertEquals(i, ParseLong.parseHex(s)); }