Skip to main content

nwr/
lib.rs

1extern crate log;
2
3mod libs;
4
5pub use crate::libs::io::*;
6pub use crate::libs::linalg::*;
7pub use crate::libs::matrix::*;
8pub use crate::libs::newick::*;
9pub use crate::libs::taxonomy::*;
10
11#[cfg(test)]
12mod tests {
13    use super::*;
14
15    #[test]
16    fn test_io_functions() {
17        // Test read_newick function
18        let tree = read_newick("tests/newick/abc.nwk");
19        assert!(tree.to_newick().is_ok());
20
21        // Test format_tree function
22        let newick = "(A,B);";
23        let tree = phylotree::tree::Tree::from_newick(newick).unwrap();
24        assert_eq!(format_tree(&tree, "  "), "(\n  A,\n  B\n);");
25    }
26
27    #[test]
28    fn test_newick_functions() {
29        let newick = "((A,B),C);";
30        let mut tree = phylotree::tree::Tree::from_newick(newick).unwrap();
31
32        // Test tree sorting functions
33        order_tree_an(&mut tree, "an");
34        assert!(tree.to_newick().is_ok());
35
36        order_tree_nd(&mut tree, "nd");
37        assert!(tree.to_newick().is_ok());
38
39        // Test node name retrieval
40        let names = get_names(&tree);
41        assert!(names.contains(&"A".to_string()));
42    }
43}