JAL-1270 test added for separatorListToArray
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Sep 2015 08:43:11 +0000 (09:43 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 14 Sep 2015 08:43:11 +0000 (09:43 +0100)
test/jalview/bin/JalviewLiteTest.java [new file with mode: 0644]

diff --git a/test/jalview/bin/JalviewLiteTest.java b/test/jalview/bin/JalviewLiteTest.java
new file mode 100644 (file)
index 0000000..047aae8
--- /dev/null
@@ -0,0 +1,39 @@
+package jalview.bin;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.util.Arrays;
+
+import org.testng.annotations.Test;
+
+
+public class JalviewLiteTest
+{
+
+  @Test(groups = "Functional")
+  public void testSeparatorListToArray()
+  {
+    assertNull(JalviewLite.separatorListToArray(null, "|"));
+    assertNull(JalviewLite.separatorListToArray("", "|"));
+    assertNull(JalviewLite.separatorListToArray("|", "|"));
+    assertNull(JalviewLite.separatorListToArray("abc", "abc"));
+
+    String [] array = JalviewLite.separatorListToArray("abc|def|ghi|", "|");
+    assertEquals(3, array.length);
+    assertEquals("abc", array[0]);
+    assertEquals("def", array[1]);
+    assertEquals("ghi", array[2]);
+
+    assertEquals("[abc]",
+            Arrays.toString(JalviewLite.separatorListToArray("abc|", "|")));
+    assertEquals("[abc]", Arrays.toString(JalviewLite.separatorListToArray(
+            "abcxy", "xy")));
+
+    // these fail:
+    // assertEquals("[abc]",
+    // Arrays.toString(JalviewLite.separatorListToArray("|abc", "|")));
+    // assertEquals("[abc]", Arrays.toString(JalviewLite.separatorListToArray(
+    // "abc|||", "|")));
+  }
+}