17 lines
594 B
Rust
17 lines
594 B
Rust
use leetcode::word_pattern::word_pattern;
|
|
|
|
use test_case::test_case;
|
|
|
|
#[test_case("abba", "dog cat cat dog", true; "example 1")]
|
|
#[test_case("abba", "dog cat cat fish", false; "example 2")]
|
|
#[test_case("aaaa", "dog cat cat dog", false; "example 3")]
|
|
#[test_case("abba", "dog dog dog dog", false; "unique key value pair")]
|
|
#[test_case("aaa", "aa aa aa aa", false; "longer string")]
|
|
#[test_case("he", "unit", false; "longer pattern")]
|
|
fn test_word_pattern(pattern: &str, string: &str, expected: bool) {
|
|
assert_eq!(
|
|
word_pattern(pattern.to_string(), string.to_string()),
|
|
expected
|
|
);
|
|
}
|