From: Jim Procter Date: Wed, 9 Jun 2021 15:35:11 +0000 (+0100) Subject: JAL-3840 failing test - show that addGaps overflows X-Git-Tag: Release_2_11_1_5~7^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ee9d0c3d15494dc2dd73fedf44994b689847aa9b;p=jalview.git JAL-3840 failing test - show that addGaps overflows --- diff --git a/src/jalview/datamodel/ResidueCount.java b/src/jalview/datamodel/ResidueCount.java index 74eb887..b21dd77 100644 --- a/src/jalview/datamodel/ResidueCount.java +++ b/src/jalview/datamodel/ResidueCount.java @@ -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 diff --git a/test/jalview/datamodel/ResidueCountTest.java b/test/jalview/datamodel/ResidueCountTest.java index 4eb6dbf..e90e1a9 100644 --- a/test/jalview/datamodel/ResidueCountTest.java +++ b/test/jalview/datamodel/ResidueCountTest.java @@ -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")