MCPcopy Create free account
hub / github.com/e2wugui/zeze / testOrder

Method testOrder

ZezeJava/ZezeJavaTest/src/Temp/TestBigInt.java:38–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 }
37
38 public void testOrder() {
39 var rand = ThreadLocalRandom.current();
40 var id1 = new Id128();
41 var id2 = new Id128();
42 var bb1 = ByteBuffer.Allocate(24);
43 var bb2 = ByteBuffer.Allocate(24);
44 for (int i = 0; i < 1_000_000; i++) {
45 id1.assign(rand.nextLong() >> rand.nextInt(64), rand.nextLong() >> rand.nextInt(64));
46 id2.assign(rand.nextLong() >> rand.nextInt(64), rand.nextLong() >> rand.nextInt(64));
47 bb1.Reset();
48 bb2.Reset();
49 id1.encode(bb1);
50 id2.encode(bb2);
51 if (Integer.signum(id1.compareTo(id2)) != Integer.signum(bb1.compareTo(bb2))) {
52 logger.error("Id128 order error: {}; {},{}; compare={},{}",
53 String.format("%016X_%016X, %016X_%016X",
54 id1.getHigh(), id1.getLow(), id2.getHigh(), id2.getLow()),
55 bb1, bb2, id1.compareTo(id2), bb1.compareTo(bb2));
56 fail();
57 }
58 id2.decode(bb1);
59 assertEquals(id1, id2);
60 }
61 }
62
63 public static void main(String[] args) {
64 var count = 10000_0000;

Callers

nothing calls this directly

Calls 12

AllocateMethod · 0.95
assignMethod · 0.95
encodeMethod · 0.95
compareToMethod · 0.95
getHighMethod · 0.95
getLowMethod · 0.95
decodeMethod · 0.95
currentMethod · 0.80
formatMethod · 0.80
ResetMethod · 0.65
nextLongMethod · 0.45
nextIntMethod · 0.45

Tested by

no test coverage detected