From a0f5d824a990f6ca892ab90cebd783e074b96696 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 27 Jun 2017 21:16:00 +0100 Subject: [PATCH] JAL-2541 more useful assert message Conflicts: test/jalview/commands/EditCommandTest.java --- test/jalview/commands/EditCommandTest.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/jalview/commands/EditCommandTest.java b/test/jalview/commands/EditCommandTest.java index 326104a..ac47555 100644 --- a/test/jalview/commands/EditCommandTest.java +++ b/test/jalview/commands/EditCommandTest.java @@ -796,13 +796,36 @@ public class EditCommandTest * undo ready for next cut */ testee.undoCommand(new AlignmentI[] { alignment }); - int size = seq0.getSequenceFeatures().size(); - assertEquals(func(5), size); + sfs = seq0.getSequenceFeatures(); + assertEquals("After undo of " + msg, func(5), sfs.size()); + verifyUndo(from, to, sfs); } } } /** + * Check that after Undo, every feature has start/end that match its original + * "start" and "end" properties + * + * @param from + * @param to + * @param sfs + */ + protected void verifyUndo(int from, int to, List sfs) + { + for (SequenceFeature sf : sfs) + { + final int oldFrom = ((Integer) sf.getValue("from")).intValue(); + final int oldTo = ((Integer) sf.getValue("to")).intValue(); + String msg = String.format( + "Undo cut of [%d-%d], feature at [%d-%d] ", from + 1, to + 1, + oldFrom, oldTo); + assertEquals(msg + "start", oldFrom, sf.getBegin()); + assertEquals(msg + "end", oldTo, sf.getEnd()); + } + } + + /** * Helper method to check a feature has been correctly relocated after a cut * * @param sf -- 1.7.10.2