From 7c5c3338cd812c15bb608e405a2c4e9edcc1edbc Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Thu, 14 Dec 2017 17:28:05 -0800 Subject: [PATCH] Test in place for engine option string --- src/options.rs | 2 ++ tests/lib.rs | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/options.rs b/src/options.rs index 56c63bc..e4df90a 100644 --- a/src/options.rs +++ b/src/options.rs @@ -94,6 +94,8 @@ impl EngineOption { // TODO: This should be tested in isolation as well // This should handle the case where optional min max var are specified as well. // pattern match the engine option type and convert it to the correct string. + // EVERYTHING SHOULD BE TRIVIALLY CASTABLE INTO A STRING + // NO MATCHING NEEDED....PROBABLY format!("PUT THE FULL COMMAND STRING HERE!") } } diff --git a/tests/lib.rs b/tests/lib.rs index 8e8104d..200ab29 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -49,7 +49,7 @@ fn send_readyok() { #[test] fn engine_option_equality() { let name = constants::HASH; - let option_type = EngineOptionType::Check; + let option_type = EngineOptionType::Spin; let option_data1 = [(EngineOptionDataType::DefaultVal, EngineOptionData::Int(1)), (EngineOptionDataType::Min, EngineOptionData::Int(1)), @@ -75,3 +75,23 @@ fn engine_option_equality() { 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: name, + option_type: option_type, + option_data: option_data1, + }; + + let expected = "option name hash type spin default 1 min 1 max 128"; + assert_eq!(o.option_string(), expected); +}