diff --git a/parsing_handlers/src/java/tweak_import_declarations.rs b/parsing_handlers/src/java/tweak_import_declarations.rs index 7e14bc5..d484845 100644 --- a/parsing_handlers/src/java/tweak_import_declarations.rs +++ b/parsing_handlers/src/java/tweak_import_declarations.rs @@ -67,3 +67,37 @@ pub fn tweak_import_declarations(root: CSTNode<'_>) -> CSTNode<'_> { } } } + +#[cfg(test)] +mod tests { + use model::{ + cst_node::{NonTerminal, Terminal}, + CSTNode, + }; + + #[test] + fn if_the_root_is_not_a_program_we_just_return_it() { + let root = CSTNode::Terminal(Terminal { + kind: "terminal", + value: "not_a_program", + ..Default::default() + }); + + assert_eq!(super::tweak_import_declarations(root.clone()), root); + } + + #[test] + fn if_somehow_the_root_is_a_terminal_node_we_just_return_it() { + let root = CSTNode::NonTerminal(NonTerminal { + kind: "program", + children: vec![CSTNode::Terminal(Terminal { + kind: "terminal", + value: "not_an_import_declaration", + ..Default::default() + })], + ..Default::default() + }); + + assert_eq!(super::tweak_import_declarations(root.clone()), root); + } +}