1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertTrue; |
26 |
|
|
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
|
29 |
|
import org.testng.annotations.BeforeClass; |
30 |
|
import org.testng.annotations.Test; |
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 6 |
Complexity Density: 0.15 |
|
32 |
|
public class SparseCountTest |
33 |
|
{ |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
35 |
1 |
@BeforeClass(alwaysRun = true)... |
36 |
|
public void setUpJvOptionPane() |
37 |
|
{ |
38 |
1 |
JvOptionPane.setInteractiveMode(false); |
39 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
40 |
|
} |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
42 |
1 |
@Test(groups = "Functional")... |
43 |
|
public void testAdd() |
44 |
|
{ |
45 |
1 |
SparseCount p = new SparseCount(8); |
46 |
1 |
p.add('a', 1); |
47 |
1 |
p.add('b', 2); |
48 |
1 |
p.add('a', 3); |
49 |
1 |
p.add('b', -4); |
50 |
1 |
assertEquals(p.size(), 2); |
51 |
1 |
assertEquals(p.get('a'), 4); |
52 |
1 |
assertEquals(p.get('b'), -2); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
55 |
1 |
@Test(groups = "Functional")... |
56 |
|
public void testPut() |
57 |
|
{ |
58 |
1 |
SparseCount p = new SparseCount(8); |
59 |
1 |
p.put('a', 3); |
60 |
1 |
p.add('b', 2); |
61 |
1 |
p.put('b', 4); |
62 |
1 |
assertEquals(p.size(), 2); |
63 |
1 |
assertEquals(p.get('a'), 3); |
64 |
1 |
assertEquals(p.get('b'), 4); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
70 |
1 |
@Test(groups = "Functional")... |
71 |
|
public void testOverflow() |
72 |
|
{ |
73 |
1 |
SparseCount p = new SparseCount(8); |
74 |
1 |
p.put('a', Short.MAX_VALUE - 1); |
75 |
1 |
p.add('a', 1); |
76 |
1 |
assertFalse(p.isUsingInt()); |
77 |
1 |
p.add('a', 1); |
78 |
1 |
assertTrue(p.isUsingInt()); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
84 |
1 |
@Test(groups = "Functional")... |
85 |
|
public void testUnderflow() |
86 |
|
{ |
87 |
1 |
SparseCount p = new SparseCount(8); |
88 |
1 |
p.put('a', Short.MIN_VALUE + 1); |
89 |
1 |
p.add('a', -1); |
90 |
1 |
assertFalse(p.isUsingInt()); |
91 |
1 |
p.add('a', -1); |
92 |
1 |
assertTrue(p.isUsingInt()); |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
95 |
1 |
@Test(groups = "Functional")... |
96 |
|
public void testKeyAt_ValueAt() |
97 |
|
{ |
98 |
1 |
SparseCount p = new SparseCount(8); |
99 |
1 |
p.put('W', 12); |
100 |
1 |
p.put('K', 9); |
101 |
1 |
p.put('R', 6); |
102 |
1 |
assertEquals(p.size(), 3); |
103 |
1 |
assertEquals(p.keyAt(0), 'K'); |
104 |
1 |
assertEquals(p.valueAt(0), 9); |
105 |
1 |
assertEquals(p.keyAt(1), 'R'); |
106 |
1 |
assertEquals(p.valueAt(1), 6); |
107 |
1 |
assertEquals(p.keyAt(2), 'W'); |
108 |
1 |
assertEquals(p.valueAt(2), 12); |
109 |
|
} |
110 |
|
|
111 |
|
} |