Skip to content

Commit

Permalink
Smallest pos int unit tests (Rust)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuamegnauth54 committed May 19, 2024
1 parent 72c5b35 commit 54de381
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Rust/jobspls/src/codility/smallest_pos_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,29 @@ where
})
.find(|val| !hayset.contains(val))
}

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

#[test]
fn missing_one_pos_is_found() {
let actual = smallest_pos_int(&[2, 3, 4]).expect("Should find a value");
let expected = 1;
assert_eq!(expected, actual);
}

#[test]
fn missing_one_neg_is_found() {
let actual = smallest_pos_int(&[-1, -2]).expect("Should find a value");
let expected = 1;
assert_eq!(expected, actual);
}

#[test]
fn missing_one_zero_is_found() {
let actual = smallest_pos_int(&[0]).expect("Should find a value");
let expected = 1;
assert_eq!(expected, actual);
}
}

0 comments on commit 54de381

Please sign in to comment.