From a718393f87a8396c8e7733f579d955126c707f4e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 9 Jun 2021 16:35:11 +0100 Subject: [PATCH] JAL-3840 failing test - show that addGaps overflows --- src/jalview/datamodel/ResidueCount.java | 2 +- test/jalview/datamodel/ResidueCountTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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") -- 1.7.10.2