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.junit.Test;
26
27
28
29
30
31
32
33 public class ShortArrayComparatorTest
34 {
35 @Test
36 public void testShortArrayComparator()
37 {
38 ShortArrayComparator comparator = new ShortArrayComparator();
39
40
41 assertEquals( 0, comparator.compare( null, null ) );
42 assertEquals( 0, comparator.compare( new short[]
43 {}, new short[]
44 {} ) );
45 assertEquals( 0, comparator.compare( new short[]
46 { ( short ) 1, ( short ) 2 }, new short[]
47 { ( short ) 1, ( short ) 2 } ) );
48
49
50 assertEquals( 1, comparator.compare( new short[]
51 {}, null ) );
52 assertEquals( 1, comparator.compare( new short[]
53 { ( short ) 1 }, null ) );
54 assertEquals( 1, comparator.compare( new short[]
55 { ( short ) 1, ( short ) 2 }, new short[]
56 { ( short ) 1, ( short ) 1 } ) );
57 assertEquals( 1, comparator.compare( new short[]
58 { ( short ) 1, ( short ) 2, ( short ) 1 }, new short[]
59 { ( short ) 1, ( short ) 2 } ) );
60 assertEquals( 1, comparator.compare( new short[]
61 { ( short ) 1, ( short ) 2 }, new short[]
62 { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
63
64
65 assertEquals( -1, comparator.compare( null, new short[]
66 {} ) );
67 assertEquals( -1, comparator.compare( null, new short[]
68 { ( short ) 1, ( short ) 2 } ) );
69 assertEquals( -1, comparator.compare( null, new short[]
70 { ( short ) -1, ( short ) 2 } ) );
71 assertEquals( -1, comparator.compare( new short[]
72 {}, new short[]
73 { ( short ) 1, ( short ) 2 } ) );
74 assertEquals( -1, comparator.compare( new short[]
75 {}, new short[]
76 { ( short ) -1, ( short ) 2 } ) );
77 assertEquals( -1, comparator.compare( new short[]
78 { ( short ) -1, ( short ) 1 }, new short[]
79 { ( short ) 1, ( short ) 1, ( short ) 2 } ) );
80 short[] array = new short[3];
81 array[0] = ( short ) 1;
82 array[1] = ( short ) 2;
83 assertEquals( -1, comparator.compare( new short[]
84 { ( short ) 1, ( short ) 2 }, array ) );
85 }
86 }