use std::path::PathBuf; use dupnamegen::{namegen, Naming}; #[cfg(unix)] #[test] fn path_nodot() { let mut gen = namegen("/tmp/hello", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("/tmp/hello (1)")); assert_eq!(gen(), PathBuf::from("/tmp/hello (2)")); } #[cfg(unix)] #[test] fn nodot() { let mut gen = namegen("hello", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("hello (1)")); assert_eq!(gen(), PathBuf::from("hello (2)")); } #[cfg(unix)] #[test] fn path_simpleext() { let mut gen = namegen("/tmp/hello.txt", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("/tmp/hello (1).txt")); assert_eq!(gen(), PathBuf::from("/tmp/hello (2).txt")); } #[cfg(unix)] #[test] fn nodot_simpleext() { let mut gen = namegen("hello.txt", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("hello (1).txt")); assert_eq!(gen(), PathBuf::from("hello (2).txt")); } #[cfg(unix)] #[test] fn path_dotfile() { let mut gen = namegen("/tmp/.hello", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("/tmp/.hello (1)")); assert_eq!(gen(), PathBuf::from("/tmp/.hello (2)")); } #[cfg(unix)] #[test] fn dotfile_noext() { let mut gen = namegen(".hello", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from(".hello (1)")); assert_eq!(gen(), PathBuf::from(".hello (2)")); } #[cfg(unix)] #[test] fn path_dotfile_withext() { let mut gen = namegen("/tmp/.hello.txt", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("/tmp/.hello (1).txt")); assert_eq!(gen(), PathBuf::from("/tmp/.hello (2).txt")); } #[cfg(unix)] #[test] fn dotfile_withext() { let mut gen = namegen(".hello.txt", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from(".hello (1).txt")); assert_eq!(gen(), PathBuf::from(".hello (2).txt")); } #[cfg(unix)] #[test] fn path_lua() { let mut gen = namegen("/tmp/lua-5.4.7.tar.gz", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("/tmp/lua-5.4.7.tar (1).gz")); assert_eq!(gen(), PathBuf::from("/tmp/lua-5.4.7.tar (2).gz")); } #[cfg(unix)] #[test] fn lua() { let mut gen = namegen("lua-5.4.7.tar.gz", Naming::WinLike, 1).unwrap(); assert_eq!(gen(), PathBuf::from("lua-5.4.7.tar (1).gz")); assert_eq!(gen(), PathBuf::from("lua-5.4.7.tar (2).gz")); } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :