Browse Source

Engine option equality done...finally

ag-yep
Taylor Bockman 7 years ago
parent
commit
54cab71bd7
  1. 7
      src/lib.rs
  2. 6
      src/options.rs
  3. 20
      tests/lib.rs

7
src/lib.rs

@ -53,12 +53,7 @@ where
{
pub fn new(name: &'a str, author: &'a str,
reader: R, writer: W, engine_options: Vec<options::EngineOption>) -> Engine<'a, R, W> {
Engine {
name: name,
author: author,
reader: reader,
writer: writer,
engine_options: engine_options,
Engine { name, author, reader, writer, engine_options,
}
}

6
src/options.rs

@ -46,7 +46,7 @@ pub mod constants {
}
/// The `EngineOptionType` type used to indicate what type of option the GUI should display
#[derive(Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum EngineOptionType {
Check,
Spin,
@ -64,7 +64,7 @@ pub enum EngineOptionData {
Text(String),
}
#[derive(Debug, Hash, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
/// The `EngineOptionDataType` type used to indicate the type of the `EngineOption` setting
pub enum EngineOptionDataType {
DefaultVal, // `Default` is reserved so `DefaultVal` is used
@ -86,7 +86,7 @@ impl EngineOption {
/// Constructs a new EngineOption of type T
pub fn new(name: &'static str, option_type: EngineOptionType,
option_data: HashMap<EngineOptionDataType, EngineOptionData>) -> EngineOption {
EngineOption { name, option_type, option_data }
EngineOption { name, option_type, option_data, }
}
pub fn option_string(&self) -> String {

20
tests/lib.rs

@ -50,14 +50,28 @@ fn send_readyok() {
fn engine_option_equality() {
let name = constants::HASH;
let option_type = EngineOptionType::Check;
let option_data =
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 o1 = EngineOption { name, option_type, option_data };
let o2 = EngineOption { name, option_type, option_data };
let o2 = EngineOption {
name: name,
option_type: option_type,
option_data: option_data2,
};
assert_eq!(o1, o2);
}

Loading…
Cancel
Save