You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
749 B
33 lines
749 B
/*
|
|
sort
|
|
This problem requires you to implement a sorting algorithm
|
|
you can use bubble sorting, insertion sorting, heap sorting, etc.
|
|
*/
|
|
// I AM NOT DONE
|
|
|
|
fn sort<T>(array: &mut [T]){
|
|
//TODO
|
|
}
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_sort_1() {
|
|
let mut vec = vec![37, 73, 57, 75, 91, 19, 46, 64];
|
|
sort(&mut vec);
|
|
assert_eq!(vec, vec![19, 37, 46, 57, 64, 73, 75, 91]);
|
|
}
|
|
#[test]
|
|
fn test_sort_2() {
|
|
let mut vec = vec![1];
|
|
sort(&mut vec);
|
|
assert_eq!(vec, vec![1]);
|
|
}
|
|
#[test]
|
|
fn test_sort_3() {
|
|
let mut vec = vec![99, 88, 77, 66, 55, 44, 33, 22, 11];
|
|
sort(&mut vec);
|
|
assert_eq!(vec, vec![11, 22, 33, 44, 55, 66, 77, 88, 99]);
|
|
}
|
|
} |