getWildcardMatchingTestCases returns a list of test cases for the Wildcard Matching problem
()
| 15 | |
| 16 | // getWildcardMatchingTestCases returns a list of test cases for the Wildcard Matching problem |
| 17 | func getWildcardMatchingTestCases() []testCaseWildcardMatching { |
| 18 | return []testCaseWildcardMatching{ |
| 19 | {"aa", "a*", true}, // '*' can match zero or more characters |
| 20 | {"aa", "a", false}, // No match due to no wildcard |
| 21 | {"ab", "?*", true}, // '?' matches any single character, '*' matches remaining |
| 22 | {"abcd", "a*d", true}, // '*' matches the characters between 'a' and 'd' |
| 23 | {"abcd", "a*c", false}, // No match as 'c' doesn't match the last character 'd' |
| 24 | {"abc", "*", true}, // '*' matches the entire string |
| 25 | {"abc", "a*c", true}, // '*' matches 'b' |
| 26 | {"abc", "a?c", true}, // '?' matches 'b' |
| 27 | {"abc", "a?d", false}, // '?' cannot match 'd' |
| 28 | {"", "", true}, // Both strings empty, so they match |
| 29 | {"a", "?", true}, // '?' matches any single character |
| 30 | {"a", "*", true}, // '*' matches any number of characters, including one |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // TestIsMatch tests the IsMatch function with various test cases |
| 35 | func TestIsMatch(t *testing.T) { |