-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathsort.rs
86 lines (77 loc) · 1.9 KB
/
sort.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use indoc::indoc;
mod utils;
#[test]
fn sort_name() {
assert_eq!(
utils::run_cmd(&["--sort", "name", "tests/data"]),
indoc!(
"143 B ┌─ cassildas_song.md
143 B ┌─ the_yellow_king
100 B ├─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
1241 B data
3 directories, 6 files"
),
"Failed to sort alphabetically by file name"
)
}
#[test]
fn sort_name_dir_order() {
assert_eq!(
utils::run_cmd(&["--sort", "name", "--dir-order", "first", "tests/data"]),
indoc!(
"143 B ┌─ cassildas_song.md
143 B ┌─ the_yellow_king
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
100 B ├─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
1241 B data
3 directories, 6 files"
)
);
assert_eq!(
utils::run_cmd(&["--sort", "name", "--dir-order", "last", "tests/data"]),
indoc!(
"100 B ┌─ nylarlathotep.txt
161 B ├─ nemesis.txt
83 B ├─ necronomicon.txt
143 B │ ┌─ cassildas_song.md
143 B ├─ the_yellow_king
446 B │ ┌─ lipsum.txt
446 B ├─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
1241 B data
3 directories, 6 files"
)
);
}
#[test]
fn sort_size() {
assert_eq!(
utils::run_cmd(&["--sort", "rsize", "tests/data"]),
indoc!(
"446 B ┌─ lipsum.txt
446 B ┌─ lipsum
308 B │ ┌─ polaris.txt
308 B ├─ dream_cycle
161 B ├─ nemesis.txt
143 B │ ┌─ cassildas_song.md
143 B ├─ the_yellow_king
100 B ├─ nylarlathotep.txt
83 B ├─ necronomicon.txt
1241 B data
3 directories, 6 files"
),
"Failed to sort by descending size"
)
}