use std::fmt;
#[derive(PartialEq, Debug)]
pub enum Join {
To,
ToNot,
NotTo,
}
impl fmt::Display for Join {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let join = match *self {
Join::To => "to",
Join::ToNot => "to not",
Join::NotTo => "not to",
};
fmt.write_str(join)
}
}
impl Join {
pub fn is_assertion(&self) -> bool {
*self == Join::To
}
}
#[cfg(test)]
mod tests {
use super::Join;
use matchers::{be_equal_to, be_true, be_false};
#[test]
fn join_should_display_correct_text() {
expect!(Join::To.to_string()).to(be_equal_to("to"));
expect!(Join::ToNot.to_string()).to(be_equal_to("to not"));
expect!(Join::NotTo.to_string()).to(be_equal_to("not to"));
}
#[test]
fn join_might_be_assertion_or_negation() {
expect!(Join::To.is_assertion()).to(be_true());
expect!(Join::ToNot.is_assertion()).to(be_false());
expect!(Join::NotTo.is_assertion()).to(be_false());
}
}