Skip to content

Commit f013692

Browse files
committed
test(medium): add spec for find the duplicate number
1 parent 5f882d9 commit f013692

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/medium/find_the_duplicate_number.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,20 @@ pub fn find_duplicate(nums: Vec<i32>) -> i32 {
4747
4848
4949
*/
50+
51+
#[cfg(test)]
52+
mod tests {
53+
use super::*;
54+
55+
#[test]
56+
fn test_find_duplicate() {
57+
assert_eq!(find_duplicate(vec![1, 3, 4, 2, 2]), 2);
58+
assert_eq!(find_duplicate(vec![3, 1, 3, 4, 2]), 3);
59+
}
60+
61+
#[test]
62+
fn test_find_duplicate_with_10_values() {
63+
assert_eq!(find_duplicate(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 9]), 9);
64+
assert_eq!(find_duplicate(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 8]), 8);
65+
}
66+
}

0 commit comments

Comments
 (0)