From: gmungoc Date: Mon, 6 Jul 2015 15:23:21 +0000 (+0100) Subject: JAL-1081 unit tests added X-Git-Tag: Release_2_10_0~586 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=c68345ea70104804843434148dd1a8b206903409;hp=6c9641bac3b88be7bc98788a0cd1fb1c969c380f;p=jalview.git JAL-1081 unit tests added --- diff --git a/test/jalview/analysis/RnaTest.java b/test/jalview/analysis/RnaTest.java new file mode 100644 index 0000000..165192c --- /dev/null +++ b/test/jalview/analysis/RnaTest.java @@ -0,0 +1,58 @@ +package jalview.analysis; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.fail; + +import jalview.analysis.SecStrConsensus.SimpleBP; + +import java.util.Vector; + +import org.testng.annotations.Test; +public class RnaTest +{ + @Test + public void testGetSimpleBPs() throws WUSSParseException + { + String rna = "([{})]"; // JAL-1081 example + Vector bps = Rna.GetSimpleBPs(rna); + assertEquals(3, bps.size()); + + /* + * the base pairs are added in the order in which the matching base is found + */ + assertEquals(2, bps.get(0).bp5); // { + assertEquals(3, bps.get(0).bp3); // } + assertEquals(0, bps.get(1).bp5); // ( + assertEquals(4, bps.get(1).bp3); // ) + assertEquals(1, bps.get(2).bp5); // [ + assertEquals(5, bps.get(2).bp3); // ] + } + + @Test + public void testGetSimpleBPs_unmatchedOpener() + { + String rna = "(([{})]"; + try + { + Rna.GetSimpleBPs(rna); + fail("expected exception"); + } catch (WUSSParseException e) + { + // expected + } + } + + @Test + public void testGetSimpleBPs_unmatchedCloser() + { + String rna = "([{})]]"; + try + { + Rna.GetSimpleBPs(rna); + fail("expected exception"); + } catch (WUSSParseException e) + { + // expected + } + } +}