Added tests for process(...) and parse_args(...).

This commit is contained in:
Aaron Weiss 2014-09-25 15:58:50 -04:00
parent 6f7673e53e
commit c9060dc89a

View file

@ -157,3 +157,24 @@ fn parse_args(line: &str) -> Vec<&str> {
}
}).collect()
}
#[test]
fn process_line_test() {
let res = process(":flare.to.ca.fyrechat.net 353 pickles = #pickles :pickles awe\r\n").unwrap();
let (source, command, args) = res;
assert_eq!(source, "flare.to.ca.fyrechat.net");
assert_eq!(command, "353");
assert_eq!(args, vec!["pickles", "=", "#pickles", "pickles awe"]);
let res = process("PING :flare.to.ca.fyrechat.net\r\n").unwrap();
let (source, command, args) = res;
assert_eq!(source, "");
assert_eq!(command, "PING");
assert_eq!(args, vec!["flare.to.ca.fyrechat.net"]);
}
#[test]
fn process_args_test() {
let res = parse_args("PRIVMSG #vana :hi");
assert_eq!(res, vec!["#vana", "hi"])
}