mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 06:02:36 +00:00
add/fix tests
This commit is contained in:
parent
81c7c77123
commit
411c9880d2
2 changed files with 61 additions and 7 deletions
|
@ -423,7 +423,7 @@ mod tests {
|
||||||
("ASCII1234-_", 11),
|
("ASCII1234-_", 11),
|
||||||
("制作样本。", 10),
|
("制作样本。", 10),
|
||||||
("日本語", 6),
|
("日本語", 6),
|
||||||
("샘플은 무료로 드리겠습니다", 26),
|
("샘플은 무료로 드리겠습니다", 28),
|
||||||
("👩🐩", 4),
|
("👩🐩", 4),
|
||||||
("🔬", 2),
|
("🔬", 2),
|
||||||
] {
|
] {
|
||||||
|
@ -454,10 +454,10 @@ mod tests {
|
||||||
// Add 3 characters for the icons.
|
// Add 3 characters for the icons.
|
||||||
("Hello,world!", 24),
|
("Hello,world!", 24),
|
||||||
("ASCII1234-_", 13),
|
("ASCII1234-_", 13),
|
||||||
("File with space", 17),
|
("File with space", 19),
|
||||||
("制作样本。", 12),
|
("制作样本。", 12),
|
||||||
("日本語", 8),
|
("日本語", 8),
|
||||||
("샘플은 무료로 드리겠습니다", 28),
|
("샘플은 무료로 드리겠습니다", 30),
|
||||||
("👩🐩", 6),
|
("👩🐩", 6),
|
||||||
("🔬", 4),
|
("🔬", 4),
|
||||||
] {
|
] {
|
||||||
|
@ -487,10 +487,10 @@ mod tests {
|
||||||
for (s, l) in [
|
for (s, l) in [
|
||||||
("Hello,world!", 22),
|
("Hello,world!", 22),
|
||||||
("ASCII1234-_", 11),
|
("ASCII1234-_", 11),
|
||||||
("File with space", 15),
|
("File with space", 17),
|
||||||
("制作样本。", 10),
|
("制作样本。", 10),
|
||||||
("日本語", 6),
|
("日本語", 6),
|
||||||
("샘플은 무료로 드리겠습니다", 26),
|
("샘플은 무료로 드리겠습니다", 28),
|
||||||
("👩🐩", 4),
|
("👩🐩", 4),
|
||||||
("🔬", 2),
|
("🔬", 2),
|
||||||
] {
|
] {
|
||||||
|
@ -528,10 +528,10 @@ mod tests {
|
||||||
for (s, l) in [
|
for (s, l) in [
|
||||||
("Hello,world!", 22),
|
("Hello,world!", 22),
|
||||||
("ASCII1234-_", 11),
|
("ASCII1234-_", 11),
|
||||||
("File with space", 15),
|
("File with space", 17),
|
||||||
("制作样本。", 10),
|
("制作样本。", 10),
|
||||||
("日本語", 6),
|
("日本語", 6),
|
||||||
("샘플은 무료로 드리겠습니다", 26),
|
("샘플은 무료로 드리겠습니다", 28),
|
||||||
("👩🐩", 4),
|
("👩🐩", 4),
|
||||||
("🔬", 2),
|
("🔬", 2),
|
||||||
] {
|
] {
|
||||||
|
|
|
@ -654,6 +654,60 @@ mod test {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let file_path = tmp_dir.path().join("a$a.txt");
|
||||||
|
File::create(&file_path).expect("failed to create file");
|
||||||
|
let meta = file_path.metadata().expect("failed to get metas");
|
||||||
|
|
||||||
|
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||||
|
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||||
|
let name = Name::new(&file_path, file_type);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
" \'a$a.txt\'".to_string().with(Color::AnsiValue(184)),
|
||||||
|
name.render(
|
||||||
|
&colors,
|
||||||
|
&icons,
|
||||||
|
&DisplayOption::FileName,
|
||||||
|
HyperlinkOption::Never
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
let file_path = tmp_dir.path().join("\\.txt");
|
||||||
|
File::create(&file_path).expect("failed to create file");
|
||||||
|
let meta = file_path.metadata().expect("failed to get metas");
|
||||||
|
|
||||||
|
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||||
|
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||||
|
let name = Name::new(&file_path, file_type);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
" \'\\.txt\'".to_string().with(Color::AnsiValue(184)),
|
||||||
|
name.render(
|
||||||
|
&colors,
|
||||||
|
&icons,
|
||||||
|
&DisplayOption::FileName,
|
||||||
|
HyperlinkOption::Never
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
let file_path = tmp_dir.path().join("\"\'.txt");
|
||||||
|
File::create(&file_path).expect("failed to create file");
|
||||||
|
let meta = file_path.metadata().expect("failed to get metas");
|
||||||
|
|
||||||
|
let colors = Colors::new(color::ThemeOption::NoLscolors);
|
||||||
|
let file_type = FileType::new(&meta, None, &Permissions::from(&meta));
|
||||||
|
let name = Name::new(&file_path, file_type);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
" \'\"\'\\\'\'.txt\'".to_string().with(Color::AnsiValue(184)),
|
||||||
|
name.render(
|
||||||
|
&colors,
|
||||||
|
&icons,
|
||||||
|
&DisplayOption::FileName,
|
||||||
|
HyperlinkOption::Never
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
let file_path = tmp_dir.path().join("file\nnewline.txt");
|
let file_path = tmp_dir.path().join("file\nnewline.txt");
|
||||||
File::create(&file_path).expect("failed to create file");
|
File::create(&file_path).expect("failed to create file");
|
||||||
let meta = file_path.metadata().expect("failed to get metas");
|
let meta = file_path.metadata().expect("failed to get metas");
|
||||||
|
|
Loading…
Reference in a new issue