use core::fmt;
use crate::condition::Condition;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Or {
pub(crate) left: Box<Condition>,
pub(crate) right: Box<Condition>,
}
impl fmt::Display for Or {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.left.fmt(f)?;
f.write_str(" OR ")?;
self.right.fmt(f)
}
}
#[cfg(test)]
mod test {
use crate::{condition::Or, Path};
use pretty_assertions::assert_eq;
#[test]
fn or() {
let a = "a".parse::<Path>().unwrap();
let b = "b".parse::<Path>().unwrap();
let c = "c".parse::<Path>().unwrap();
let d = "d".parse::<Path>().unwrap();
let condition = Or {
left: a.greater_than(b).into(),
right: c.less_than(d).into(),
};
assert_eq!("a > b OR c < d", condition.to_string());
}
}