1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.android; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.fail; |
25 |
|
|
26 |
|
import jalview.gui.JvOptionPane; |
27 |
|
|
28 |
|
import org.testng.annotations.BeforeClass; |
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
|
|
| 84.3% |
Uncovered Elements: 8 (51) |
Complexity: 12 |
Complexity Density: 0.26 |
|
35 |
|
public class SparseIntArrayTest |
36 |
|
{ |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
38 |
1 |
@BeforeClass(alwaysRun = true)... |
39 |
|
public void setUpJvOptionPane() |
40 |
|
{ |
41 |
1 |
JvOptionPane.setInteractiveMode(false); |
42 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
43 |
|
} |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
45 |
1 |
@Test(groups = "Functional")... |
46 |
|
public void testPut() |
47 |
|
{ |
48 |
1 |
SparseIntArray counter = new SparseIntArray(); |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
1 |
counter.put(Integer.MAX_VALUE, Integer.MIN_VALUE); |
54 |
1 |
counter.put(Integer.MIN_VALUE, Integer.MAX_VALUE); |
55 |
1 |
assertEquals(counter.get(Integer.MAX_VALUE), Integer.MIN_VALUE); |
56 |
1 |
assertEquals(counter.get(Integer.MIN_VALUE), Integer.MAX_VALUE); |
57 |
|
} |
58 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.23 |
1PASS
|
|
59 |
1 |
@Test(groups = "Functional")... |
60 |
|
public void testAdd() |
61 |
|
{ |
62 |
1 |
SparseIntArray counter = new SparseIntArray(); |
63 |
|
|
64 |
1 |
assertEquals(counter.add('P', 2), 2); |
65 |
1 |
assertEquals(counter.add('P', 3), 5); |
66 |
1 |
counter.put('Q', 7); |
67 |
1 |
assertEquals(counter.add('Q', 4), 11); |
68 |
|
|
69 |
1 |
counter.put('x', Integer.MAX_VALUE); |
70 |
1 |
try |
71 |
|
{ |
72 |
1 |
counter.add('x', 1); |
73 |
0 |
fail("expected exception"); |
74 |
|
} catch (ArithmeticException e) |
75 |
|
{ |
76 |
|
|
77 |
|
} |
78 |
|
|
79 |
1 |
counter.put('y', Integer.MIN_VALUE); |
80 |
1 |
try |
81 |
|
{ |
82 |
1 |
counter.add('y', -1); |
83 |
0 |
fail("expected exception"); |
84 |
|
} catch (ArithmeticException e) |
85 |
|
{ |
86 |
|
|
87 |
|
} |
88 |
|
} |
89 |
|
|
|
|
| 77.8% |
Uncovered Elements: 6 (27) |
Complexity: 7 |
Complexity Density: 0.26 |
1PASS
|
|
90 |
1 |
@Test(groups = "Functional")... |
91 |
|
public void testCheckOverflow() |
92 |
|
{ |
93 |
|
|
94 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE, 0); |
95 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE, -1); |
96 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE, Integer.MIN_VALUE); |
97 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE, -Integer.MAX_VALUE); |
98 |
1 |
SparseIntArray.checkOverflow(0, -Integer.MAX_VALUE); |
99 |
1 |
SparseIntArray.checkOverflow(0, Integer.MIN_VALUE); |
100 |
1 |
SparseIntArray.checkOverflow(Integer.MIN_VALUE, 0); |
101 |
1 |
SparseIntArray.checkOverflow(Integer.MIN_VALUE, 1); |
102 |
1 |
SparseIntArray.checkOverflow(Integer.MIN_VALUE, Integer.MAX_VALUE); |
103 |
|
|
104 |
|
|
105 |
1 |
try |
106 |
|
{ |
107 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE, 1); |
108 |
0 |
fail("expected exception"); |
109 |
|
} catch (ArithmeticException e) |
110 |
|
{ |
111 |
|
|
112 |
|
} |
113 |
1 |
try |
114 |
|
{ |
115 |
1 |
SparseIntArray.checkOverflow(Integer.MAX_VALUE - 1, 2); |
116 |
0 |
fail("expected exception"); |
117 |
|
} catch (ArithmeticException e) |
118 |
|
{ |
119 |
|
|
120 |
|
} |
121 |
1 |
try |
122 |
|
{ |
123 |
1 |
SparseIntArray.checkOverflow(1, Integer.MAX_VALUE); |
124 |
0 |
fail("expected exception"); |
125 |
|
} catch (ArithmeticException e) |
126 |
|
{ |
127 |
|
|
128 |
|
} |
129 |
1 |
try |
130 |
|
{ |
131 |
1 |
SparseIntArray.checkOverflow(Integer.MIN_VALUE, -1); |
132 |
0 |
fail("expected exception"); |
133 |
|
} catch (ArithmeticException e) |
134 |
|
{ |
135 |
|
|
136 |
|
} |
137 |
1 |
try |
138 |
|
{ |
139 |
1 |
SparseIntArray.checkOverflow(Integer.MIN_VALUE + 1, -2); |
140 |
0 |
fail("expected exception"); |
141 |
|
} catch (ArithmeticException e) |
142 |
|
{ |
143 |
|
|
144 |
|
} |
145 |
1 |
try |
146 |
|
{ |
147 |
1 |
SparseIntArray.checkOverflow(-1, Integer.MIN_VALUE); |
148 |
0 |
fail("expected exception"); |
149 |
|
} catch (ArithmeticException e) |
150 |
|
{ |
151 |
|
|
152 |
|
} |
153 |
|
} |
154 |
|
|
155 |
|
} |