#![cfg(feature = "sort")] use commons::sort::*; #[test] fn test_bubble_sort() { let mut elems = vec![0, 3, -1, 1, 2, 5, 4, 2, 2]; let sorted = vec![-1, 0, 1, 2, 2, 2, 3, 4, 5]; bubble_sort(&mut elems); assert_eq!(sorted, elems); } #[test] fn test_insertion_sort() { let mut elems = vec![0, 3, 2, -1]; let sorted = vec![-1, 0, 2, 3]; insertion_sort(&mut elems); assert_eq!(sorted, elems); } #[test] fn test_selection_sort() { let mut elems = vec![0, 3, 2, -1]; let sorted = vec![-1, 0, 2, 3]; selection_sort(&mut elems); assert_eq!(sorted, elems); } #[test] fn test_shell_sort() { let mut elems = vec![0, 3, 2, -1]; let sorted = vec![-1, 0, 2, 3]; shell_sort(&mut elems); assert_eq!(sorted, elems); } #[test] fn test_quick_sort() { let mut elems = vec![0, 3, 2, -1]; let sorted = vec![-1, 0, 2, 3]; quick_sort(&mut elems); assert_eq!(sorted, elems); }