1
Fork 0
leetcode/tests/word_pattern.rs

17 lines
594 B
Rust
Raw Normal View History

2022-04-10 20:41:34 +00:00
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
);
}