diff --git a/src/ir.rs b/src/ir.rs index 93a00e3654ae37586ea128ca967a0605cb0368ba..82ed8306d443d71d798796b0f0f63a958ec35584 100644 --- a/src/ir.rs +++ b/src/ir.rs @@ -638,68 +638,4 @@ impl<'n> Iterator for BranchIterator<'n> { } #[cfg(test)] -mod tests { - use super::*; - use crate::ir::relation::*; - use pretty_assertions::assert_eq; - use std::fs; - use std::path::Path; - - #[test] - fn plan_no_top() { - let path = Path::new("") - .join("tests") - .join("artifactory") - .join("ir") - .join("plan_no_top.yaml"); - let s = fs::read_to_string(path).unwrap(); - assert_eq!( - QueryPlannerError::InvalidPlan, - Plan::from_yaml(&s).unwrap_err() - ); - } - - #[test] - fn plan_oor_top() { - let path = Path::new("") - .join("tests") - .join("artifactory") - .join("ir") - .join("plan_oor_top.yaml"); - let s = fs::read_to_string(path).unwrap(); - assert_eq!( - QueryPlannerError::ValueOutOfRange, - Plan::from_yaml(&s).unwrap_err() - ); - } - - #[test] - fn get_node() { - let mut plan = Plan::empty(); - - let t = Table::new_seg("t", vec![Column::new("a", Type::Boolean)], &["a"]).unwrap(); - plan.add_rel(t); - - let scan = Relational::new_scan("t", &mut plan).unwrap(); - let scan_id = vec_alloc(&mut plan.nodes, Node::Relational(scan)); - - if let Node::Relational(Relational::ScanRelation { relation, .. }) = - plan.get_node(scan_id).unwrap() - { - assert_eq!(relation, "t"); - } else { - panic!("Unexpected node returned!") - } - } - - #[test] - fn get_node_oor() { - let plan = Plan::empty(); - assert_eq!( - QueryPlannerError::ValueOutOfRange, - plan.get_node(42).unwrap_err() - ); - } - - //TODO: add relation test -} +mod tests; diff --git a/src/ir/tests.rs b/src/ir/tests.rs new file mode 100644 index 0000000000000000000000000000000000000000..d9f1ac96343437d261de5a5d216c83f64ad005a9 --- /dev/null +++ b/src/ir/tests.rs @@ -0,0 +1,63 @@ +use super::*; +use crate::ir::relation::*; +use pretty_assertions::assert_eq; +use std::fs; +use std::path::Path; + +#[test] +fn plan_no_top() { + let path = Path::new("") + .join("tests") + .join("artifactory") + .join("ir") + .join("plan_no_top.yaml"); + let s = fs::read_to_string(path).unwrap(); + assert_eq!( + QueryPlannerError::InvalidPlan, + Plan::from_yaml(&s).unwrap_err() + ); +} + +#[test] +fn plan_oor_top() { + let path = Path::new("") + .join("tests") + .join("artifactory") + .join("ir") + .join("plan_oor_top.yaml"); + let s = fs::read_to_string(path).unwrap(); + assert_eq!( + QueryPlannerError::ValueOutOfRange, + Plan::from_yaml(&s).unwrap_err() + ); +} + +#[test] +fn get_node() { + let mut plan = Plan::empty(); + + let t = Table::new_seg("t", vec![Column::new("a", Type::Boolean)], &["a"]).unwrap(); + plan.add_rel(t); + + let scan = Relational::new_scan("t", &mut plan).unwrap(); + let scan_id = vec_alloc(&mut plan.nodes, Node::Relational(scan)); + + if let Node::Relational(Relational::ScanRelation { relation, .. }) = + plan.get_node(scan_id).unwrap() + { + assert_eq!(relation, "t"); + } else { + panic!("Unexpected node returned!") + } +} + +#[test] +fn get_node_oor() { + let plan = Plan::empty(); + assert_eq!( + QueryPlannerError::ValueOutOfRange, + plan.get_node(42).unwrap_err() + ); +} + +//TODO: add relation test