From 3e4960cd512411a430115676d4381aaee68e81dc Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 15 Jun 2016 11:25:07 +0100 Subject: [PATCH] JAL-2025 unit tests added --- src/jalview/gui/StructureChooser.java | 2 +- test/jalview/gui/StructureChooserTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 426f092..9464f66 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -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*\\]", "") diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index c2209d6..ae6bf38 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -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)); + } } -- 1.7.10.2