From 00bed7dabd957e08890925f92c1a239efd961a9a Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Fri, 10 Dec 2021 13:50:40 -0800 Subject: [PATCH] add some tests documenting behavior --- src/cmd_line.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/cmd_line.rs b/src/cmd_line.rs index 46d16a3..f1a81ab 100644 --- a/src/cmd_line.rs +++ b/src/cmd_line.rs @@ -230,6 +230,59 @@ mod tests { ); } + #[test] + fn test_files_to_open() { + let args: Vec = vec!["neovide", "./foo.txt", "./bar.md"] + .iter() + .map(|s| s.to_string()) + .collect(); + + let _accessing_settings = ACCESSING_SETTINGS.lock().unwrap(); + handle_command_line_arguments(args).expect("Could not parse arguments"); + assert_eq!( + SETTINGS.get::().neovim_args, + vec!["./foo.txt", "./bar.md"] + ); + } + + #[test] + fn test_files_to_open_with_passthrough() { + let args: Vec = vec!["neovide", "./foo.txt", "./bar.md", "--", "--clean"] + .iter() + .map(|s| s.to_string()) + .collect(); + + let _accessing_settings = ACCESSING_SETTINGS.lock().unwrap(); + handle_command_line_arguments(args).expect("Could not parse arguments"); + assert_eq!( + SETTINGS.get::().neovim_args, + vec!["--clean", "./foo.txt", "./bar.md"] + ); + } + + #[test] + fn test_files_to_open_with_flag() { + let args: Vec = vec!["neovide", "./foo.txt", "./bar.md", "--geometry=42x24"] + .iter() + .map(|s| s.to_string()) + .collect(); + + let _accessing_settings = ACCESSING_SETTINGS.lock().unwrap(); + handle_command_line_arguments(args).expect("Could not parse arguments"); + assert_eq!( + SETTINGS.get::().neovim_args, + vec!["./foo.txt", "./bar.md"] + ); + + assert_eq!( + SETTINGS.get::().geometry, + Dimensions { + width: 42, + height: 24 + } + ); + } + #[test] fn test_geometry() { let args: Vec = vec!["neovide", "--geometry=42x24"]