1
Fork 0
leetcode/tests/two_sum.rs

13 lines
411 B
Rust

use leetcode::two_sum::two_sum;
use test_case::test_case;
#[test_case(&[2, 7, 11, 15], 9, &[0, 1]; "1")]
#[test_case(&[3, 2, 4], 6, &[1, 2]; "2")]
#[test_case(&[3, 3], 6, &[0, 1]; "3")]
#[test_case(&[3, 2, 3], 6, &[0, 2]; "4")]
#[test_case(&[-3, 4, 3, 90], 0, &[0, 2]; "negative")]
fn test_two_sum(numbers: &[i32], target: i32, expected: &[i32]) {
assert_eq!(two_sum(numbers.to_vec(), target), expected);
}