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.

52 lines
1.5 KiB

extern crate uci;
use uci::Engine;
use uci::options::constants;
use uci::options::{ EngineOption, EngineOptionType, EngineOptionDataType, EngineOptionData };
#[test]
fn engine_option_equality() {
let name = constants::HASH;
let option_type = EngineOptionType::Spin;
let option_data1 =
[(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)),
(EngineOptionDataType::Min, EngineOptionData::Int(1)),
(EngineOptionDataType::Max, EngineOptionData::Int(128))
].iter().cloned().collect();
let option_data2 =
[(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)),
(EngineOptionDataType::Min, EngineOptionData::Int(1)),
(EngineOptionDataType::Max, EngineOptionData::Int(128))
].iter().cloned().collect();
let o1 = EngineOption {
name: name,
option_type: option_type,
option_data: option_data1,
};
let o2 = EngineOption {
name: name,
option_type: option_type,
option_data: option_data2,
};
assert_eq!(o1, o2);
}
#[test]
fn engine_option_string() {
let name = constants::HASH;
let option_type = EngineOptionType::Spin;
let option_data =
[(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)),
(EngineOptionDataType::Min, EngineOptionData::Int(1)),
(EngineOptionDataType::Max, EngineOptionData::Int(128))
].iter().cloned().collect();
let o = EngineOption { name, option_type, option_data, };
let expected = "option name Hash type spin default 1 min 1 max 128\n";
assert_eq!(o.to_string(), expected);
}