JAL-1081 unit tests added
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 6 Jul 2015 15:23:21 +0000 (16:23 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 6 Jul 2015 15:23:21 +0000 (16:23 +0100)
test/jalview/analysis/RnaTest.java [new file with mode: 0644]

diff --git a/test/jalview/analysis/RnaTest.java b/test/jalview/analysis/RnaTest.java
new file mode 100644 (file)
index 0000000..165192c
--- /dev/null
@@ -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<SimpleBP> 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
+    }
+  }
+}