forked from TheAlgorithms/Rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
37 lines (35 loc) · 796 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#[macro_use]
extern crate lazy_static;
pub mod backtracking;
pub mod big_integer;
pub mod ciphers;
pub mod compression;
pub mod conversions;
pub mod data_structures;
pub mod dynamic_programming;
pub mod general;
pub mod graph;
pub mod math;
pub mod navigation;
pub mod searching;
pub mod sorting;
pub mod string;
#[cfg(test)]
mod tests {
use super::sorting;
#[test]
fn quick_sort() {
//descending
let mut ve1 = vec![6, 5, 4, 3, 2, 1];
sorting::quick_sort(&mut ve1);
for i in 0..ve1.len() - 1 {
assert!(ve1[i] <= ve1[i + 1]);
}
//pre-sorted
let mut ve2 = vec![1, 2, 3, 4, 5, 6];
sorting::quick_sort(&mut ve2);
for i in 0..ve2.len() - 1 {
assert!(ve2[i] <= ve2[i + 1]);
}
}
}