From c68345ea70104804843434148dd1a8b206903409 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 6 Jul 2015 16:23:21 +0100 Subject: [PATCH] JAL-1081 unit tests added --- test/jalview/analysis/RnaTest.java | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/jalview/analysis/RnaTest.java 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 + } + } +} -- 1.7.10.2