#[cfg(test)]
mod tests {
use converge::Converge;
extern crate pretty_assertions;
#[derive(Converge, PartialEq)]
struct Simple {
number: std::option::Option<u32>,
}
impl Simple {
pub fn new_empty() -> Simple {
Simple {
number: std::option::Option::None,
}
}
pub fn new_with(value: u32) -> Simple {
Simple {
number: std::option::Option::Some(value),
}
}
}
#[test]
fn test_self_some_default_some() {
let some_1 = Simple::new_with(1);
let some_2 = Simple::new_with(2);
let out = some_1.converge(some_2);
assert!(out == Simple::new_with(1));
}
#[test]
fn test_self_none_default_some() {
let empty = Simple::new_empty();
let some_2 = Simple::new_with(2);
let out = empty.converge(some_2);
assert!(out == Simple::new_with(2));
}
#[test]
fn test_self_none_default_none() {
let empty_1 = Simple::new_empty();
let empty_2 = Simple::new_empty();
let out = empty_1.converge(empty_2);
assert!(out == Simple::new_empty());
}
#[test]
fn test_self_some_default_none() {
let some_1 = Simple::new_with(1);
let empty = Simple::new_empty();
let out = some_1.converge(empty);
assert!(out == Simple::new_with(1));
}
}