1
Fork 0
leetcode/tests/valid_parenthesis.rs

18 lines
622 B
Rust

use leetcode::valid_parenthesis::is_valid;
use test_case::test_case;
#[test_case("", true; "empty")]
#[test_case("[]", true; "simple")]
#[test_case("[()]", true; "nested")]
#[test_case("[{}()]", true; "multiple nested")]
#[test_case("[", false; "only closing")]
#[test_case("[()", false; "missing closing")]
#[test_case("[(", false; "only opening")]
#[test_case("[)", false; "mismatched simple")]
#[test_case("[(}]", false; "mismatched nested")]
#[test_case("([{}()]}", false; "mismatched multiple nested")]
fn test_valid_parenthesis(input: &str, expected: bool) {
assert_eq!(is_valid(input.to_string()), expected);
}