1
Fork 0
leetcode/tests/contains_duplicate_ii.rs

13 lines
551 B
Rust
Raw Normal View History

2022-04-11 12:02:46 +00:00
use leetcode::contains_duplicate_ii::contains_nearby_duplicate;
use test_case::test_case;
#[test_case(&[1, 2, 3, 1], 3, true; "example 1")]
#[test_case(&[1, 0, 1, 1], 1, true; "example 2")]
#[test_case(&[1, 2, 3, 1, 2, 3], 2, false; "example 3")]
#[test_case(&[99, 99], 2, true; "range higher than numbers")]
#[test_case(&(-25000..=30000).collect::<Vec<i32>>(), 35000, false; "massive input")]
fn test_contains_duplicate_ii(numbers: &[i32], range: i32, expected: bool) {
assert_eq!(contains_nearby_duplicate(numbers.to_vec(), range), expected);
}