1 package jalview.ext.android;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.fail;
6 import org.testng.annotations.Test;
8 public class SparseShortArrayTest
10 @Test(groups = "Functional")
13 SparseShortArray counter = new SparseShortArray();
16 * either key or value may be in the range of short
18 counter.put(Short.MAX_VALUE, Short.MIN_VALUE);
19 counter.put(Short.MIN_VALUE, Short.MAX_VALUE);
21 // put a too large value
24 counter.put(0, Short.MAX_VALUE + 1);
25 fail("Expected exception");
26 } catch (ArithmeticException e)
31 // put a too small value
34 counter.put(1, Short.MIN_VALUE - 1);
35 fail("Expected exception");
36 } catch (ArithmeticException e)
41 // put a too large key
44 counter.put(Short.MAX_VALUE + 1, 0);
45 fail("Expected exception");
46 } catch (ArithmeticException e)
51 // put a too small key
54 counter.put(Short.MIN_VALUE - 1, 2);
55 fail("Expected exception");
56 } catch (ArithmeticException e)
62 @Test(groups = "Functional")
65 SparseShortArray counter = new SparseShortArray();
67 assertEquals(counter.add('P', 2), 2);
68 assertEquals(counter.add('P', 3), 5);
70 assertEquals(counter.add('Q', 4), 11);
72 // increment giving overflow
73 counter.put('x', Short.MAX_VALUE);
77 fail("Expected exception");
78 } catch (ArithmeticException e)
83 // decrement giving underflow
84 counter.put('y', Short.MIN_VALUE);
88 fail("Expected exception");
89 } catch (ArithmeticException e)