1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase;
20
21 import org.apache.hadoop.hbase.util.Bytes;
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 @Category(SmallTests.class)
27 public class TestCellUtil {
28
29 @Test
30 public void testOverlappingKeys() {
31 byte[] empty = HConstants.EMPTY_BYTE_ARRAY;
32 byte[] a = Bytes.toBytes("a");
33 byte[] b = Bytes.toBytes("b");
34 byte[] c = Bytes.toBytes("c");
35 byte[] d = Bytes.toBytes("d");
36
37
38 Assert.assertTrue(CellUtil.overlappingKeys(a, b, a, b));
39 Assert.assertTrue(CellUtil.overlappingKeys(a, c, a, b));
40 Assert.assertTrue(CellUtil.overlappingKeys(a, b, a, c));
41 Assert.assertTrue(CellUtil.overlappingKeys(b, c, a, c));
42 Assert.assertTrue(CellUtil.overlappingKeys(a, c, b, c));
43 Assert.assertTrue(CellUtil.overlappingKeys(a, d, b, c));
44 Assert.assertTrue(CellUtil.overlappingKeys(b, c, a, d));
45
46 Assert.assertTrue(CellUtil.overlappingKeys(empty, b, a, b));
47 Assert.assertTrue(CellUtil.overlappingKeys(empty, b, a, c));
48
49 Assert.assertTrue(CellUtil.overlappingKeys(a, b, empty, b));
50 Assert.assertTrue(CellUtil.overlappingKeys(a, b, empty, c));
51
52 Assert.assertTrue(CellUtil.overlappingKeys(a, empty, a, b));
53 Assert.assertTrue(CellUtil.overlappingKeys(a, empty, a, c));
54
55 Assert.assertTrue(CellUtil.overlappingKeys(a, b, empty, empty));
56 Assert.assertTrue(CellUtil.overlappingKeys(empty, empty, a, b));
57
58
59 Assert.assertFalse(CellUtil.overlappingKeys(a, b, c, d));
60 Assert.assertFalse(CellUtil.overlappingKeys(c, d, a, b));
61
62 Assert.assertFalse(CellUtil.overlappingKeys(b, c, c, d));
63 Assert.assertFalse(CellUtil.overlappingKeys(b, c, c, empty));
64 Assert.assertFalse(CellUtil.overlappingKeys(b, c, d, empty));
65 Assert.assertFalse(CellUtil.overlappingKeys(c, d, b, c));
66 Assert.assertFalse(CellUtil.overlappingKeys(c, empty, b, c));
67 Assert.assertFalse(CellUtil.overlappingKeys(d, empty, b, c));
68
69 Assert.assertFalse(CellUtil.overlappingKeys(b, c, a, b));
70 Assert.assertFalse(CellUtil.overlappingKeys(b, c, empty, b));
71 Assert.assertFalse(CellUtil.overlappingKeys(b, c, empty, a));
72 Assert.assertFalse(CellUtil.overlappingKeys(a,b, b, c));
73 Assert.assertFalse(CellUtil.overlappingKeys(empty, b, b, c));
74 Assert.assertFalse(CellUtil.overlappingKeys(empty, a, b, c));
75 }
76 }