1 package jalview.util.matcher;
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertFalse;
5 import static org.testng.Assert.assertTrue;
7 import org.testng.annotations.Test;
9 public class KeyedMatcherTest
12 public void testMatches()
15 * a numeric matcher - MatcherTest covers more conditions
17 KeyedMatcherI km = new KeyedMatcher("AF", Condition.GE, -2F);
18 assertTrue(km.matches(key -> "-2"));
19 assertTrue(km.matches(key -> "-1"));
20 assertFalse(km.matches(key -> "-3"));
21 assertFalse(km.matches(key -> ""));
22 assertFalse(km.matches(key -> "junk"));
23 assertFalse(km.matches(key -> null));
26 * a string pattern matcher
28 km = new KeyedMatcher("AF", Condition.Contains, "Cat");
29 assertTrue(km.matches(key -> "AF".equals(key) ? "raining cats and dogs"
34 public void testToString()
36 KeyedMatcherI km = new KeyedMatcher("AF", Condition.LT, 1.2f);
37 assertEquals(km.toString(), "AF LT 1.2");
41 public void testGetKey()
43 KeyedMatcherI km = new KeyedMatcher("AF", Condition.GE, -2F);
44 assertEquals(km.getKey(), "AF");
48 public void testGetMatcher()
50 KeyedMatcherI km = new KeyedMatcher("AF", Condition.GE, -2F);
51 assertEquals(km.getMatcher().getCondition(), Condition.GE);
52 assertEquals(km.getMatcher().getFloatValue(), -2F);
53 assertEquals(km.getMatcher().getPattern(), "-2.0");