use super::cmd::{parse, Cmd}; #[test] fn test_write_cmd() { let input = "write foo.xlsx"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Write(Some("foo.xlsx"))); } #[test] fn test_short_write_cmd() { let input = "w foo.xlsx"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Write(Some("foo.xlsx"))); } #[test] fn test_insert_rows_cmd() { let input = "insert-rows 1"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::InsertRow(1)); } #[test] fn test_insert_rows_cmd_short() { let input = "ir 1"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::InsertRow(1)); } #[test] fn test_insert_cols_cmd() { let input = "insert-cols 1"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::InsertColumns(1)); } #[test] fn test_insert_cols_cmd_short() { let input = "ic 1"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::InsertColumns(1)); } #[test] fn test_edit_cmd() { let input = "edit path.txt"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Edit("path.txt")); } #[test] fn test_edit_cmd_short() { let input = "e path.txt"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Edit("path.txt")); } #[test] fn test_help_cmd() { let input = "help topic"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Help(Some("topic"))); } #[test] fn test_help_cmd_short() { let input = "? topic"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Help(Some("topic"))); } #[test] fn test_quit_cmd_short() { let input = "q"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Quit); } #[test] fn test_quit_cmd() { let input = "quit"; let result = parse(input); assert!(result.is_ok()); let output = result.unwrap(); assert!(output.is_some()); let cmd = output.unwrap(); assert_eq!(cmd, Cmd::Quit); } // TODO(zaphar): Interaction testing for input.