From: gmungoc Date: Fri, 11 May 2018 10:57:56 +0000 (+0100) Subject: JAL-2986 failing test added X-Git-Tag: Release_2_11_0~40 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5055db1699e872051d4228244e3df116660b4570;p=jalview.git JAL-2986 failing test added --- diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index 5a14514..67f1081 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -247,7 +247,9 @@ public class SequenceTest sq.sequenceChanged(); assertEquals(6, sq.findIndex(9)); - sq = new Sequence("test/8-13", "-A--B-C-D-E-F--"); + final String aligned = "-A--B-C-D-E-F--"; + assertEquals(15, aligned.length()); + sq = new Sequence("test/8-13", aligned); assertEquals(2, sq.findIndex(8)); sq.sequenceChanged(); assertEquals(5, sq.findIndex(9)); @@ -263,6 +265,29 @@ public class SequenceTest // beyond end returns last residue column sq.sequenceChanged(); assertEquals(13, sq.findIndex(99)); + + /* + * residue before sequence 'end' but beyond end of sequence returns + * length of sequence (last column) (rightly or wrongly!) + */ + sq = new Sequence("test/8-15", "A-B-C-"); // trailing gap case + assertEquals(6, sq.getLength()); + sq.sequenceChanged(); + assertEquals(sq.getLength(), sq.findIndex(14)); + sq = new Sequence("test/8-99", "-A--B-C-D"); // trailing residue case + sq.sequenceChanged(); + assertEquals(sq.getLength(), sq.findIndex(65)); + + /* + * residue after sequence 'start' but before first residue returns + * zero (before first column) (rightly or wrongly!) + */ + sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case + sq.sequenceChanged(); + assertEquals(0, sq.findIndex(3)); + sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case + sq.sequenceChanged(); + assertEquals(0, sq.findIndex(2)); } /** @@ -1410,6 +1435,28 @@ public class SequenceTest // find C given C assertEquals(6, sq.findIndex(10, new SequenceCursor(sq, 10, 6, 0))); + + /* + * sequence 'end' beyond end of sequence returns length of sequence + * (for compatibility with pre-cursor code) + */ + sq = new Sequence("test/8-99", "-A--B-C-D-E-F--"); // trailing gap case + sq.findIndex(10); // establishes a cursor + assertEquals(sq.getLength(), sq.findIndex(65)); + sq = new Sequence("test/8-99", "-A--B-C-D-E-F"); // trailing residue case + sq.findIndex(10); // establishes a cursor + assertEquals(sq.getLength(), sq.findIndex(65)); + + /* + * residue after sequence 'start' but before first residue should return + * zero (for compatibility with pre-cursor code) + */ + sq = new Sequence("test/8-15", "-A-B-C-"); // leading gap case + sq.findIndex(10); // establishes a cursor + assertEquals(0, sq.findIndex(3)); + sq = new Sequence("test/8-15", "A-B-C-"); // leading residue case + sq.findIndex(10); // establishes a cursor + assertEquals(0, sq.findIndex(2)); } @Test(groups = { "Functional" })