()
| 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; |
nothing calls this directly
no test coverage detected