From 79cc4e6584ce0a91c841959e563c976670f4aeee Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 11 Mar 2016 12:14:34 +0000 Subject: [PATCH] JAL-1270 unit test for SequenceIdMatcher.SeqIdName --- src/jalview/analysis/SequenceIdMatcher.java | 2 +- test/jalview/analysis/SequenceIdMatcherTest.java | 78 ++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/jalview/analysis/SequenceIdMatcherTest.java diff --git a/src/jalview/analysis/SequenceIdMatcher.java b/src/jalview/analysis/SequenceIdMatcher.java index 454bc09..8351686 100755 --- a/src/jalview/analysis/SequenceIdMatcher.java +++ b/src/jalview/analysis/SequenceIdMatcher.java @@ -272,7 +272,7 @@ public class SequenceIdMatcher return r; } - private class SeqIdName + class SeqIdName { String id; diff --git a/test/jalview/analysis/SequenceIdMatcherTest.java b/test/jalview/analysis/SequenceIdMatcherTest.java new file mode 100644 index 0000000..eb0fc47 --- /dev/null +++ b/test/jalview/analysis/SequenceIdMatcherTest.java @@ -0,0 +1,78 @@ +package jalview.analysis; + +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; + +import jalview.analysis.SequenceIdMatcher.SeqIdName; +import jalview.datamodel.SequenceI; + +import org.testng.annotations.Test; + +public class SequenceIdMatcherTest +{ + + /** + * Test the method that checks for one sequence id starting with the other, + * followed by an 'allowed' separator character + */ + @Test(groups = "Functional") + public void test_seqIdNameEquals() + { + SequenceIdMatcher sequenceIdMatcher = new SequenceIdMatcher( + new SequenceI[] {}); + + /* + * target name = matcher name + word separator... + */ + SeqIdName testee = sequenceIdMatcher.new SeqIdName("A12345"); + assertTrue(testee.equals("A12345")); + assertTrue(testee.equals("A12345~")); + assertTrue(testee.equals("A12345.")); + assertTrue(testee.equals("A12345 ")); + assertTrue(testee.equals("A12345|")); + assertTrue(testee.equals("A12345#")); + assertTrue(testee.equals("A12345\\")); + assertTrue(testee.equals("A12345/")); + assertTrue(testee.equals("A12345<")); + assertTrue(testee.equals("A12345>")); + assertTrue(testee.equals("A12345!")); + assertTrue(testee.equals("A12345\"")); + assertTrue(testee.equals("A12345" + String.valueOf((char) 0x00A4))); + assertTrue(testee.equals("A12345$a")); + assertTrue(testee.equals("A12345%b")); + assertTrue(testee.equals("A12345^cd")); + assertTrue(testee.equals("A12345*efg")); + assertTrue(testee.equals("A12345)^&!")); + assertTrue(testee.equals("A12345}01&*")); + assertTrue(testee.equals("A12345[A23456")); + assertTrue(testee.equals("A12345@|Uniprot")); + assertTrue(testee.equals("A12345'whatever you want here")); + assertTrue(testee.equals("A12345,")); + assertTrue(testee.equals("A12345?")); + assertTrue(testee.equals("A12345_")); + + /* + * matcher name = target name + word separator... + */ + testee = sequenceIdMatcher.new SeqIdName("A12345#"); + assertTrue(testee.equals("A12345")); + + /* + * miscellaneous failing cases + */ + testee = sequenceIdMatcher.new SeqIdName("A12345"); + assertFalse(testee.equals((Object) null)); + assertFalse(testee.equals("")); + assertFalse(testee.equals("a12345")); + assertFalse(testee.equals("A12346|A12345")); + + testee = sequenceIdMatcher.new SeqIdName("A12345?B23456"); + assertFalse(testee.equals("B23456")); + assertFalse(testee.equals("A12345|")); + assertFalse(testee.equals("A12345?")); + + testee = sequenceIdMatcher.new SeqIdName("A12345<"); + assertFalse(testee.equals("A12345?")); + assertTrue(testee.equals("A12345<")); // bug? inconsistent + } +} -- 1.7.10.2