An implementation of the Universal Chess Interface in Rust.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
986 B

// TODO: Write parser tests before implementing the parser.
// Start with setoption and branch out from there. The commands are finite so you should be able
// to write a test for each one. Take the time to do this right so that the rest of this project is
// a cakewalk
//
// // Also remember to fix the constant thing noted in the lib.rs for uci.... lol
//
extern crate uci;
use uci::parser;
#[test]
fn parse_setoption() {
let s = "setoption name Hash value 32\n";
let expected = parser::TokenResult {
token: parser::Token::SETOPTION,
args: Some(
[
("name", parser::CommandValue::Text(String::from("Hash"))),
("value", parser::CommandValue::Int(32)),
].iter().cloned().collect()),
};
let p = parser::Parser::new();
match p.parse(s) {
Ok(r) => {
assert_eq!(r, expected);
}
Err(_) => panic!("failed to parse setoption as expected")
}
}
#[test]
fn bad_parse() {
assert_eq!(true, false);
}