100-days-of-rust/Week-08/Day-51_Asteroid-Collision/day51/tests/examples.rs

33 lines
719 B
Rust
Raw Normal View History

2024-09-14 11:16:16 +00:00
#[cfg(test)]
mod examples {
use day51::asteroid_collision;
#[test]
fn example1() {
let asteroids = &[5, 10, -5];
let res = asteroid_collision(asteroids);
assert_eq!(res, vec![5, 10]);
}
#[test]
fn example2() {
let asteroids = &[8, -8];
let res = asteroid_collision(asteroids);
assert_eq!(res, vec![]);
}
#[test]
fn example3() {
let asteroids = &[10, 2, -5];
let res = asteroid_collision(asteroids);
assert_eq!(res, vec![10]);
}
#[test]
fn example4() {
let asteroids = &[-2, -1, 1, 2];
let res = asteroid_collision(asteroids);
assert_eq!(res, vec![-2, -1, 1, 2]);
}
}