From a8f20af75d409856fc4052539c7e815fb016fa8d Mon Sep 17 00:00:00 2001 From: vorboyvo Date: Tue, 23 Sep 2025 18:23:20 -0400 Subject: [PATCH] Fixed spacing --- src/test.rs | 236 ++++++++++++++++++++++++++-------------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/src/test.rs b/src/test.rs index 189d1db..2a0c96e 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1,128 +1,128 @@ - use super::*; - use assert_approx_eq::assert_approx_eq; +use super::*; +use assert_approx_eq::assert_approx_eq; - fn simple_symmetric_tree() -> Tree { - let a = Alternative { - name: "A".to_owned() - }; - let b = Alternative { - name: "B".to_owned() - }; - let edge_a = Edge { - weight: 1.0, - destination: Tree {root: Vertex::Terminal(a)} - }; - let edge_b = Edge { - weight: 1.0, - destination: Tree {root: Vertex::Terminal(b)} - }; - let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)); - Tree {root: root} - } +fn simple_symmetric_tree() -> Tree { + let a = Alternative { + name: "A".to_owned() + }; + let b = Alternative { + name: "B".to_owned() + }; + let edge_a = Edge { + weight: 1.0, + destination: Tree {root: Vertex::Terminal(a)} + }; + let edge_b = Edge { + weight: 1.0, + destination: Tree {root: Vertex::Terminal(b)} + }; + let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)); + Tree {root: root} +} - fn simple_asymmetric_tree() -> Tree { - let a = Alternative { - name: "A".to_owned() - }; - let b = Alternative { - name: "B".to_owned() - }; - let edge_a = Edge { - weight: 3.0, - destination: Tree {root: Vertex::Terminal(a)} - }; - let edge_b = Edge { - weight: 1.0, - destination: Tree {root: Vertex::Terminal(b)} - }; - let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)); - Tree {root: root} - } +fn simple_asymmetric_tree() -> Tree { + let a = Alternative { + name: "A".to_owned() + }; + let b = Alternative { + name: "B".to_owned() + }; + let edge_a = Edge { + weight: 3.0, + destination: Tree {root: Vertex::Terminal(a)} + }; + let edge_b = Edge { + weight: 1.0, + destination: Tree {root: Vertex::Terminal(b)} + }; + let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)); + Tree {root: root} +} - fn complex_tree() -> Tree { - let a = Alternative { - name: "A".to_owned() - }; - let b = Alternative { - name: "B".to_owned() - }; - let c = Alternative { - name: "C".to_owned() - }; - let edge_a = Edge { - weight: 2.5, - destination: Tree {root: Vertex::Terminal(a)} - }; - let edge_b = Edge { - weight: 1.0, - destination: Tree {root: Vertex::Terminal(b)} - }; - let edge_ab = Edge{ - weight: 0.5, - destination: Tree { - root: Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)) - } - }; - let edge_c = Edge{ - weight: 1.0, - destination: Tree {root: Vertex::Terminal(c)} - }; - let root = Vertex::NonTerminal(Box::new(edge_ab), Box::new(edge_c)); - Tree {root: root} - } +fn complex_tree() -> Tree { + let a = Alternative { + name: "A".to_owned() + }; + let b = Alternative { + name: "B".to_owned() + }; + let c = Alternative { + name: "C".to_owned() + }; + let edge_a = Edge { + weight: 2.5, + destination: Tree {root: Vertex::Terminal(a)} + }; + let edge_b = Edge { + weight: 1.0, + destination: Tree {root: Vertex::Terminal(b)} + }; + let edge_ab = Edge{ + weight: 0.5, + destination: Tree { + root: Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b)) + } + }; + let edge_c = Edge{ + weight: 1.0, + destination: Tree {root: Vertex::Terminal(c)} + }; + let root = Vertex::NonTerminal(Box::new(edge_ab), Box::new(edge_c)); + Tree {root: root} +} - // A test for the simplest symmetric case - #[test] - fn choice_probability_test_1() { - assert_eq!(simple_symmetric_tree().choice_probability(&("A".to_owned())), 0.5); - } +// A test for the simplest symmetric case +#[test] +fn choice_probability_test_1() { + assert_eq!(simple_symmetric_tree().choice_probability(&("A".to_owned())), 0.5); +} - // A test for the simplest asymmetric case - #[test] - fn choice_probability_test_2() { - assert_eq!(simple_asymmetric_tree().choice_probability(&("A".to_owned())), 0.75); - } +// A test for the simplest asymmetric case +#[test] +fn choice_probability_test_2() { + assert_eq!(simple_asymmetric_tree().choice_probability(&("A".to_owned())), 0.75); +} - // A test for depth higher than 1 - #[test] - fn choice_probability_test_3() { - assert_approx_eq!( - complex_tree().choice_probability(&("A".to_owned())), - (2.5/(2.5+1.0))*((2.5+1.0+0.5)/(2.5+1.0+0.5+1.0)) - ); - } +// A test for depth higher than 1 +#[test] +fn choice_probability_test_3() { + assert_approx_eq!( + complex_tree().choice_probability(&("A".to_owned())), + (2.5/(2.5+1.0))*((2.5+1.0+0.5)/(2.5+1.0+0.5+1.0)) + ); +} - // A test for parsing the simplest symmetric case - #[test] - fn parser_test_1() { - assert_eq!( - { - let (_, b) = parser::subtree("([1.0]A[1.0]B)").unwrap(); - b - }, - simple_symmetric_tree() - ) - } +// A test for parsing the simplest symmetric case +#[test] +fn parser_test_1() { + assert_eq!( + { + let (_, b) = parser::subtree("([1.0]A[1.0]B)").unwrap(); + b + }, + simple_symmetric_tree() + ) +} - #[test] - fn parser_test_2() { - assert_eq!( - { - let (_, b) = parser::subtree("([3.0]A[1.0]B)").unwrap(); - b - }, - simple_asymmetric_tree() - ) - } +#[test] +fn parser_test_2() { + assert_eq!( + { + let (_, b) = parser::subtree("([3.0]A[1.0]B)").unwrap(); + b + }, + simple_asymmetric_tree() + ) +} - #[test] - fn parser_test_3() { - assert_eq!( - { - let (_, b) = parser::subtree("([0.5]([2.5]A[1.0]B)[1.0]C)").unwrap(); - b - }, - complex_tree() - ) - } +#[test] +fn parser_test_3() { + assert_eq!( + { + let (_, b) = parser::subtree("([0.5]([2.5]A[1.0]B)[1.0]C)").unwrap(); + b + }, + complex_tree() + ) +}