Skip to content

Commit

Permalink
lc: Add unittest to two sum
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Nov 14, 2023
1 parent d8f7a9a commit db8b151
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions leetcode/001.two_sum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,19 @@ fn main() {
let target = 6;
assert_eq!(solution1(nums, target), Some((0, 1)));
}

#[cfg(test)]
mod tests {
use super::solution1;

#[test]
fn test_solution1() {
let nums = &[0, 4, 3, 0];
let target = 0;
assert_eq!(solution1(nums, target), Some((0, 3)));

let nums = &[-3, 4, 3, 90];
let target = 0;
assert_eq!(solution1(nums, target), Some((0, 2)));
}
}

0 comments on commit db8b151

Please sign in to comment.