diff --git a/src/display.rs b/src/display.rs index 74788e4..21139a3 100644 --- a/src/display.rs +++ b/src/display.rs @@ -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), ] { diff --git a/src/meta/name.rs b/src/meta/name.rs index 39e34f8..a448512 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -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");