JAL-98 use Profile to store consensus, ResidueCount for fast compact
[jalview.git] / test / jalview / ext / android / SparseIntArrayTest.java
1 package jalview.ext.android;
2
3 import static org.testng.Assert.assertEquals;
4
5 import org.testng.annotations.Test;
6
7 /*
8  * Tests for SparseIntArray. Unlike SparseShortArray, SparseIntArray does not throw
9  * any exception for overflow.
10  */
11 public class SparseIntArrayTest
12 {
13   @Test(groups = "Functional")
14   public void testPut()
15   {
16     SparseIntArray counter = new SparseIntArray();
17
18     /*
19      * either key or value may be in the range of int
20      */
21     counter.put(Integer.MAX_VALUE, Integer.MIN_VALUE);
22     counter.put(Integer.MIN_VALUE, Integer.MAX_VALUE);
23     assertEquals(counter.get(Integer.MAX_VALUE), Integer.MIN_VALUE);
24     assertEquals(counter.get(Integer.MIN_VALUE), Integer.MAX_VALUE);
25   }
26
27   @Test(groups = "Functional")
28   public void testAdd()
29   {
30     SparseIntArray counter = new SparseIntArray();
31   
32     assertEquals(counter.add('P', 2), 2);
33     assertEquals(counter.add('P', 3), 5);
34     counter.put('Q', 7);
35     assertEquals(counter.add('Q', 4), 11);
36
37     counter.put('x', Integer.MAX_VALUE);
38     counter.add('x', 1);
39   
40     counter.put('y', Integer.MIN_VALUE);
41     counter.add('y', -1);
42   }
43 }