Implement testcases for command rule
This commit is contained in:
parent
d0dba5996f
commit
c7ed3ac13e
|
@ -0,0 +1,40 @@
|
||||||
|
#[cfg(test)]
|
||||||
|
use crate::tcl::commands;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_commands_working() {
|
||||||
|
let testcase_1: &str = "cmd_a;cmd_b;cmd_c";
|
||||||
|
let testcase_2: &str = "cmd_a\ncmd_b\ncmd_c";
|
||||||
|
let verify: Vec<String> = vec![
|
||||||
|
String::from("cmd_a"),
|
||||||
|
String::from("cmd_b"),
|
||||||
|
String::from("cmd_c"),
|
||||||
|
];
|
||||||
|
|
||||||
|
assert_eq!(commands(testcase_1), verify);
|
||||||
|
assert_eq!(commands(testcase_2), verify);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_commands_quotes() {
|
||||||
|
let testcase_1: &str = "cmd_a\n\"cmd_b\"\ncmd_c";
|
||||||
|
let verify_1: Vec<String> = vec![
|
||||||
|
String::from("cmd_a"),
|
||||||
|
String::from("\"cmd_b\""),
|
||||||
|
String::from("cmd_c"),
|
||||||
|
];
|
||||||
|
|
||||||
|
let testcase_2: &str = "cmd_a;\"cmd_b;cmd_c\"";
|
||||||
|
let verify_2: Vec<String> = vec![String::from("cmd_a"), String::from("\"cmd_b;cmd_c\"")];
|
||||||
|
|
||||||
|
let testcase_3: &str = "cmd_a;\"cmd_b\ncmd_c\"";
|
||||||
|
let verify_3: Vec<String> = vec![String::from("cmd_a"), String::from("\"cmd_b\ncmd_c\"")];
|
||||||
|
|
||||||
|
let case_1 = commands(testcase_1);
|
||||||
|
let case_2 = commands(testcase_2);
|
||||||
|
let case_3 = commands(testcase_3);
|
||||||
|
|
||||||
|
assert_eq!(case_1, verify_1);
|
||||||
|
assert_eq!(case_2, verify_2);
|
||||||
|
assert_eq!(case_3, verify_3);
|
||||||
|
}
|
Loading…
Reference in New Issue