|
|
|
@ -25,10 +25,6 @@ fn send_identification_data() {
|
|
|
|
|
let mut e = Engine::new("test_name", "test", &input[..], &mut output, vec!()); |
|
|
|
|
e.identify(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NOTE: This looks weird bceause you'd think it would store each insertion into the output buffer
|
|
|
|
|
// as a separate element of that buffer, but it really just appends the two strings since in reality
|
|
|
|
|
// the buffer would be flushed after reading.
|
|
|
|
|
assert_eq!(str::from_utf8(&output).unwrap_or("Unwrapping output failed in send_identification_data"), |
|
|
|
|
"id name test_name\nid author test\n"); |
|
|
|
|
} |
|
|
|
@ -86,19 +82,46 @@ fn engine_option_string() {
|
|
|
|
|
(EngineOptionDataType::Max, EngineOptionData::Int(128)) |
|
|
|
|
].iter().cloned().collect(); |
|
|
|
|
|
|
|
|
|
let o = EngineOption { |
|
|
|
|
name: name, |
|
|
|
|
option_type: option_type, |
|
|
|
|
option_data: option_data, |
|
|
|
|
}; |
|
|
|
|
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.option_string(), expected); |
|
|
|
|
assert_eq!(o.to_string(), expected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn send_available_engine_options() { |
|
|
|
|
// This should send two to three options and check the string in the
|
|
|
|
|
// buffer to make sure it's correct.
|
|
|
|
|
assert_eq!(true, false); |
|
|
|
|
let input = b"UNUSED"; |
|
|
|
|
let mut output = Vec::new(); |
|
|
|
|
|
|
|
|
|
let o1 = EngineOption { |
|
|
|
|
name: constants::HASH, |
|
|
|
|
option_type: EngineOptionType::Spin, |
|
|
|
|
option_data: [(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)), |
|
|
|
|
(EngineOptionDataType::Min, EngineOptionData::Int(1)), |
|
|
|
|
(EngineOptionDataType::Max, EngineOptionData::Int(128)) |
|
|
|
|
].iter().cloned().collect(), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let o2 = EngineOption { |
|
|
|
|
name: constants::NALIMOVPATH, |
|
|
|
|
option_type: EngineOptionType::TypeString, |
|
|
|
|
option_data: [(EngineOptionDataType::DefaultVal, EngineOptionData::Text(String::from(r"c:\"))), |
|
|
|
|
].iter().cloned().collect(), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let o3 = EngineOption { |
|
|
|
|
name: "Clear Hash", |
|
|
|
|
option_type: EngineOptionType::Button, |
|
|
|
|
option_data: [].iter().cloned().collect(), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
let mut e = Engine::new("test_name", "test", &input[..], &mut output, vec!(o1, o2, o3)); |
|
|
|
|
e.send_available_options(); |
|
|
|
|
} |
|
|
|
|
assert_eq!(str::from_utf8(&output).unwrap_or("Unwrapping output failed in send_identification_data"), |
|
|
|
|
"option name Hash type spin default 1 min 1 max 128\n\ |
|
|
|
|
option name NalimovPath type string default c:\n\ |
|
|
|
|
option name Clear Hash type button\n\ |
|
|
|
|
uciok\n"); |
|
|
|
|
} |
|
|
|
|