1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.mavibot.btree.comparator;
21
22
23 import static org.junit.Assert.assertEquals;
24
25 import org.apache.directory.mavibot.btree.comparator.ShortArrayComparator;
26 import org.junit.Test;
27
28
29
30
31
32
33
34 public class ShortArrayComparatorTest
35 {
36 @Test
37 public void testShortArrayComparator()
38 {
39 ShortArrayComparator comparator = new ShortArrayComparator();
40
41
42 assertEquals( 0, comparator.compare( null, null ) );
43 assertEquals( 0, comparator.compare( new short[]
44 {}, new short[]
45 {} ) );
46 assertEquals( 0, comparator.compare( new short[]
47 { ( short ) 1, ( short ) 2 }, new short[]
48 { ( short ) 1, ( short ) 2 } ) );
49
50
51 assertEquals( 1, comparator.compare( new short[]
52 {}, null ) );
53 assertEquals( 1, comparator.compare( new short[]
54 { ( short ) 1 }, null ) );
55 assertEquals( 1, comparator.compare( new short[]
56 { ( short ) 1, ( short ) 2 }, new short[]
57 { ( short ) 1, ( short ) 1 } ) );
58 assertEquals( 1, comparator.compare( new short[]
59 { ( short ) 1, ( short ) 2, ( short ) 1 }, new short[]
60 { ( short ) 1, ( short ) 2 } ) );
61 assertEquals( 1, comparator.compare( new short[]
62 { ( short ) 1, ( short ) 2 }, new short[]
63 { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
64
65
66 assertEquals( -1, comparator.compare( null, new short[]
67 {} ) );
68 assertEquals( -1, comparator.compare( null, new short[]
69 { ( short ) 1, ( short ) 2 } ) );
70 assertEquals( -1, comparator.compare( null, new short[]
71 { ( short ) -1, ( short ) 2 } ) );
72 assertEquals( -1, comparator.compare( new short[]
73 {}, new short[]
74 { ( short ) 1, ( short ) 2 } ) );
75 assertEquals( -1, comparator.compare( new short[]
76 {}, new short[]
77 { ( short ) -1, ( short ) 2 } ) );
78 assertEquals( -1, comparator.compare( new short[]
79 { ( short ) -1, ( short ) 1 }, new short[]
80 { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
81 short[] array = new short[3];
82 array[0] = ( short ) 1;
83 array[1] = ( short ) 2;
84 assertEquals( -1, comparator.compare( new short[]
85 { ( short ) 1, ( short ) 2 }, array ) );
86 }
87 }