--- /dev/null
+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
+ }
+}