JAL-3840 failing test - show that addGaps overflows
authorJim Procter <jprocter@issues.jalview.org>
Wed, 9 Jun 2021 15:35:11 +0000 (16:35 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 9 Jun 2021 15:40:25 +0000 (16:40 +0100)
src/jalview/datamodel/ResidueCount.java
test/jalview/datamodel/ResidueCountTest.java

index 74eb887..b21dd77 100644 (file)
@@ -70,7 +70,7 @@ public class ResidueCount
    */
   private static final String AAS = "ACDEFGHIKLMNPQRSTUVWXY";
 
-  private static final int GAP_COUNT = 0;
+  static final int GAP_COUNT = 0;
 
   /*
    * fast lookup tables holding the index into our count
index 4eb6dbf..e90e1a9 100644 (file)
@@ -92,6 +92,18 @@ public class ResidueCountTest
     assertEquals(rc.getCount('.'), 4);
     assertFalse(rc.isUsingOtherData());
     assertFalse(rc.isCountingInts());
+    
+    rc.set(ResidueCount.GAP_COUNT, Short.MAX_VALUE-2);
+    assertEquals(rc.getGapCount(), Short.MAX_VALUE-2);
+    assertFalse(rc.isCountingInts());
+    rc.addGap();
+    assertEquals(rc.getGapCount(), Short.MAX_VALUE-1);
+    assertFalse(rc.isCountingInts());
+    rc.addGap();
+    assertEquals(rc.getGapCount(), Short.MAX_VALUE);
+    rc.addGap();
+    assertTrue(rc.isCountingInts());
+    assertEquals(rc.getGapCount(), Short.MAX_VALUE+1);
   }
 
   @Test(groups = "Functional")