|
20 | 20 |
|
21 | 21 | package org.lmdbjava; |
22 | 22 |
|
| 23 | +import com.google.common.primitives.SignedBytes; |
| 24 | +import com.google.common.primitives.UnsignedBytes; |
23 | 25 | import io.netty.buffer.ByteBuf; |
24 | 26 | import static io.netty.buffer.PooledByteBufAllocator.DEFAULT; |
25 | 27 | import java.nio.ByteBuffer; |
26 | 28 | import static java.nio.charset.StandardCharsets.US_ASCII; |
| 29 | +import java.util.Comparator; |
27 | 30 | import org.agrona.DirectBuffer; |
28 | 31 | import org.agrona.concurrent.UnsafeBuffer; |
29 | 32 | import static org.hamcrest.core.Is.is; |
@@ -72,7 +75,9 @@ public static Object[] data() { |
72 | 75 | final ComparatorRunner ba = new ByteArrayRunner(); |
73 | 76 | final ComparatorRunner bb = new ByteBufferRunner(); |
74 | 77 | final ComparatorRunner netty = new NettyRunner(); |
75 | | - return new Object[]{string, db, ba, bb, netty}; |
| 78 | + final ComparatorRunner gub = new GuavaUnsignedBytes(); |
| 79 | + final ComparatorRunner gsb = new GuavaSignedBytes(); |
| 80 | + return new Object[]{string, db, ba, bb, netty, gub, gsb}; |
76 | 81 | } |
77 | 82 |
|
78 | 83 | private static byte[] buffer(final int... bytes) { |
@@ -168,6 +173,30 @@ public int compare(final byte[] o1, final byte[] o2) { |
168 | 173 | } |
169 | 174 | } |
170 | 175 |
|
| 176 | + /** |
| 177 | + * Tests using Guava's {@link SignedBytes} comparator. |
| 178 | + */ |
| 179 | + private static class GuavaSignedBytes implements ComparatorRunner { |
| 180 | + |
| 181 | + @Override |
| 182 | + public int compare(final byte[] o1, final byte[] o2) { |
| 183 | + final Comparator<byte[]> c = SignedBytes.lexicographicalComparator(); |
| 184 | + return c.compare(o1, o2); |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * Tests using Guava's {@link UnsignedBytes} comparator. |
| 190 | + */ |
| 191 | + private static class GuavaUnsignedBytes implements ComparatorRunner { |
| 192 | + |
| 193 | + @Override |
| 194 | + public int compare(final byte[] o1, final byte[] o2) { |
| 195 | + final Comparator<byte[]> c = UnsignedBytes.lexicographicalComparator(); |
| 196 | + return c.compare(o1, o2); |
| 197 | + } |
| 198 | + } |
| 199 | + |
171 | 200 | /** |
172 | 201 | * Tests {@link ByteBufProxy}. |
173 | 202 | */ |
|
0 commit comments