JAL-2830 failing test added for Replace
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 13 Nov 2017 13:43:57 +0000 (13:43 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 13 Nov 2017 13:43:57 +0000 (13:43 +0000)
src/jalview/commands/EditCommand.java
test/jalview/commands/EditCommandTest.java

index f71fb79..06f59cb 100644 (file)
@@ -806,9 +806,9 @@ public class EditCommand implements CommandI
         {
           // first edit the original dataset sequence string
           SequenceI oldds = command.seqs[i].getDatasetSequence();
-          String fullseq, osp = oldds.getSequenceAsString();
+          String osp = oldds.getSequenceAsString();
 
-          fullseq = osp.substring(0, ipos) + nogaprep
+          String fullseq = osp.substring(0, ipos) + nogaprep
                   + osp.substring(ipos + nogaprep.length());
 
           // and check if new sequence data is different..
index a0c2ccf..61ca5a6 100644 (file)
@@ -282,6 +282,27 @@ public class EditCommandTest
   }
 
   /**
+   * Test the replace command (used to manually edit a sequence)
+   */
+  @Test(groups = { "Functional" })
+  public void testReplace_withGaps()
+  {
+    SequenceI seq = new Sequence("seq", "ABC--DEF");
+    seq.createDatasetSequence();
+    assertEquals("ABCDEF", seq.getDatasetSequence().getSequenceAsString());
+
+    /*
+     * replace C- with XYZ
+     * NB arg4 = start column of selection for edit (base 0)
+     * arg5 = column after end of selection for edit
+     */
+    new EditCommand("", Action.REPLACE, "XYZ", new SequenceI[] { seq }, 2,
+            4, al);
+    assertEquals("ABXYZ-DEF", seq.getSequenceAsString());
+    assertEquals("ABXYZDEF", seq.getDatasetSequence().getSequenceAsString());
+  }
+
+  /**
    * Test replace command when it doesn't cause a sequence edit (see comment in
    */
   @Test(groups = { "Functional" })