Skip to content

Commit

Permalink
test: cover edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jpedroh committed May 2, 2024
1 parent c9cbfd8 commit c8decac
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions parsing_handlers/src/java/tweak_import_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,29 @@ pub fn tweak_import_declarations(root: CSTNode<'_>) -> CSTNode<'_> {
}
}
}

#[cfg(test)]
mod tests {
use model::{cst_node::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::Terminal(Terminal {
kind: "program",
..Default::default()
});

assert_eq!(super::tweak_import_declarations(root.clone()), root);
}
}

0 comments on commit c8decac

Please sign in to comment.