public static UUID fromString(String str) { java.util.UUID ans = NessUUID.fromString(str); return new UUID(ans.getMostSignificantBits(), ans.getLeastSignificantBits()); }
public long timeNessUuidFromString(int reps) { long accum = 0; for (int i = 0; i < reps; i++) { accum += NessUUID.fromString(testStrings[i % N_UUIDS]).getMostSignificantBits(); } return accum; }
private void testEx(String str) { try { NessUUID.fromString(hyphen1); } catch (IllegalArgumentException e) { return; } Assert.fail(str); }
@Test public void testBasic() { Assert.assertEquals(UUID.fromString(uuid), NessUUID.fromString(uuid)); Assert.assertEquals(UUID.fromString(caseSensitivity), NessUUID.fromString(caseSensitivity)); Assert.assertEquals(UUID.fromString(overflow), NessUUID.fromString(overflow)); Assert.assertEquals(UUID.fromString(zero), NessUUID.fromString(zero)); }
@Test public void testLength() { final UUID uuid = NessUUID.fromString(badLength); Assert.assertEquals(0, uuid.getMostSignificantBits()); Assert.assertEquals(0, uuid.getLeastSignificantBits()); }
UUID uuid = NessUUID.fromString("0-0-0-0-0"); uuid = NessUUID.fromString("0-0-0-0-"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("-0-0-0-0-0"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("-0-0-0-0"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("-0-0-0-"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("0--0-0-0"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("0-0-0-0-"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) { uuid = NessUUID.fromString("-1-0-0-0-0"); Assert.fail("should throw IllegalArgumentException"); } catch (IllegalArgumentException e) {
UUID actual = NessUUID.fromString("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"); UUID expected = new UUID(0xf81d4fae7dec11d0L, 0xa76500a0c91e6bf6L); Assert.assertEquals(expected, actual); actual = NessUUID.fromString("00000000-0000-1000-8000-000000000000"); expected = new UUID(0x0000000000001000L, 0x8000000000000000L); Assert.assertEquals(expected, actual); NessUUID.fromString(null); Assert.fail("No NPE"); } catch (NullPointerException e) {} NessUUID.fromString(""); Assert.fail("No IAE"); } catch (IllegalArgumentException e) {} NessUUID.fromString("f81d4fae_7dec-11d0-a765-00a0c91e6bf6"); Assert.fail("No IAE"); } catch (IllegalArgumentException e) {} NessUUID.fromString("f81d4fae-7dec_11d0-a765-00a0c91e6bf6"); Assert.fail("No IAE"); } catch (IllegalArgumentException e) {} NessUUID.fromString("f81d4fae-7dec-11d0_a765-00a0c91e6bf6"); Assert.fail("No IAE"); } catch (IllegalArgumentException e) {} NessUUID.fromString("f81d4fae-7dec-11d0-a765_00a0c91e6bf6");