JAL-2025 unit tests added
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 15 Jun 2016 10:25:07 +0000 (11:25 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 15 Jun 2016 10:25:07 +0000 (11:25 +0100)
src/jalview/gui/StructureChooser.java
test/jalview/gui/StructureChooserTest.java

index 426f092..9464f66 100644 (file)
@@ -338,7 +338,7 @@ public class StructureChooser extends GStructureChooser implements
    * @param seqName
    * @return
    */
-  private static String sanitizeSeqName(String seqName)
+  static String sanitizeSeqName(String seqName)
   {
     Objects.requireNonNull(seqName);
     return seqName.replaceAll("\\[\\d*\\]", "")
index c2209d6..ae6bf38 100644 (file)
@@ -116,4 +116,22 @@ public class StructureChooserTest
     assertTrue(sc.getDiscoveredStructuresSet().size() > 0);
 
   }
+
+  @Test(groups = { "Functional" })
+  public void sanitizeSeqNameTest()
+  {
+    String name = "ab_cdEF|fwxyz012349";
+    assertEquals(name, StructureChooser.sanitizeSeqName(name));
+
+    // remove a [nn] substring
+    name = "abcde12[345]fg";
+    assertEquals("abcde12fg", StructureChooser.sanitizeSeqName(name));
+
+    // remove characters other than a-zA-Z0-9 | or _
+    name = "ab[cd],.\t£$*!- \\\"@:e";
+    assertEquals("abcde", StructureChooser.sanitizeSeqName(name));
+
+    name = "abcde12[345a]fg";
+    assertEquals("abcde12345afg", StructureChooser.sanitizeSeqName(name));
+  }
 }