### Question:
StringMatchesPatternString { public static boolean matches(String str, String pattern) { if (str == null || pattern == null) { throw new IllegalArgumentException("Tested string either pattern string is null"); } Boolean[][] cache = new Boolean[str.length() + 1][pattern.length() + 1]; return matches(str, pattern, 0, 0, cache); }  static boolean matches(String str, String pattern);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testMatchesBothParamsNull() { matches(null, null); }
@Test(expected = IllegalArgumentException.class) public void testMatchesInputStrNull() { matches(null, "abc*a"); }
@Test(expected = IllegalArgumentException.class) public void testMatchesInputPatternNull() { matches("abc12", null); }
@Test public void testMatchesBothParamsEmpty() { assertTrue(matches("", "")); }
@Test public void testMatches1() { assertTrue(matches("", "*")); assertTrue(matches("", "**")); assertTrue(matches("", "***")); assertTrue(matches("a", "*")); assertTrue(matches("ab", "*")); assertTrue(matches("abc", "*")); assertTrue(matches("ab", "**")); assertTrue(matches("abc", "***")); assertTrue(matches("abc", "****")); }
@Test public void testMatches2() { assertFalse(matches("", "*?")); assertTrue(matches("b", "*?")); assertTrue(matches("ba", "*?")); assertTrue(matches("cba", "*?")); }
@Test public void testMatches3() { assertTrue(matches("abc", "a*c")); assertFalse(matches("abc", "a*b")); assertTrue(matches("abcdef", "abc?ef")); assertFalse(matches("abcdefa", "abc?ef")); assertTrue(matches("abcdef", "abc*ef")); assertFalse(matches("abcdefa", "abc*ef")); }
@Test public void testMatches4() { assertTrue(matches("abcbca", "ab*cbca")); assertFalse(matches("abcbca", "ab?cbca")); assertTrue(matches("abcbca", "ab*?b*ca*")); assertTrue(matches("cb", "*?*b")); assertFalse(matches("b", "*?*b")); }
@Test public void testMatches5() { assertTrue(matches("abcbca", "abcbca")); assertTrue(matches("abcbca", "******************************abcbca")); assertTrue(matches("abcbca", "******************************abcbca*")); assertFalse(matches("abcbca", "******************************abcbca?")); assertFalse(matches("abcbca", "abcbcab")); assertFalse(matches("abcbca", "abcbc")); assertTrue(matches("abcbca", "?bcbca")); assertFalse(matches("abcbca", "a?cbcab")); assertFalse(matches("abcbca", "abcb?")); }