mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-13 21:52:37 +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),
|
||||
("制作样本。", 10),
|
||||
("日本語", 6),
|
||||
("샘플은 무료로 드리겠습니다", 26),
|
||||
("샘플은 무료로 드리겠습니다", 28),
|
||||
("👩🐩", 4),
|
||||
("🔬", 2),
|
||||
] {
|
||||
|
@ -454,10 +454,10 @@ mod tests {
|
|||
// Add 3 characters for the icons.
|
||||
("Hello,world!", 24),
|
||||
("ASCII1234-_", 13),
|
||||
("File with space", 17),
|
||||
("File with space", 19),
|
||||
("制作样本。", 12),
|
||||
("日本語", 8),
|
||||
("샘플은 무료로 드리겠습니다", 28),
|
||||
("샘플은 무료로 드리겠습니다", 30),
|
||||
("👩🐩", 6),
|
||||
("🔬", 4),
|
||||
] {
|
||||
|
@ -487,10 +487,10 @@ mod tests {
|
|||
for (s, l) in [
|
||||
("Hello,world!", 22),
|
||||
("ASCII1234-_", 11),
|
||||
("File with space", 15),
|
||||
("File with space", 17),
|
||||
("制作样本。", 10),
|
||||
("日本語", 6),
|
||||
("샘플은 무료로 드리겠습니다", 26),
|
||||
("샘플은 무료로 드리겠습니다", 28),
|
||||
("👩🐩", 4),
|
||||
("🔬", 2),
|
||||
] {
|
||||
|
@ -528,10 +528,10 @@ mod tests {
|
|||
for (s, l) in [
|
||||
("Hello,world!", 22),
|
||||
("ASCII1234-_", 11),
|
||||
("File with space", 15),
|
||||
("File with space", 17),
|
||||
("制作样本。", 10),
|
||||
("日本語", 6),
|
||||
("샘플은 무료로 드리겠습니다", 26),
|
||||
("샘플은 무료로 드리겠습니다", 28),
|
||||
("👩🐩", 4),
|
||||
("🔬", 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");
|
||||
File::create(&file_path).expect("failed to create file");
|
||||
let meta = file_path.metadata().expect("failed to get metas");
|
||||
|
|
Loading…
Reference in a new issue