You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
335 B
Rust
18 lines
335 B
Rust
3 years ago
|
use rand::seq::SliceRandom;
|
||
|
use sorting;
|
||
|
use rand::thread_rng;
|
||
|
|
||
|
#[test]
|
||
|
fn bubble_sort_ascending() {
|
||
|
// Arrange
|
||
|
let mut vec: Vec<usize> = (0..20).rev().collect();
|
||
|
vec.shuffle(&mut thread_rng());
|
||
|
|
||
|
// Act
|
||
|
sorting::bubble_sort::sort(&mut vec);
|
||
|
|
||
|
// Assert
|
||
|
for i in 0..20 {
|
||
|
assert_eq!(vec[i], i);
|
||
|
}
|
||
|
}
|