Fixed spacing
This commit is contained in:
parent
6518ed8a4d
commit
a8f20af75d
60
src/test.rs
60
src/test.rs
|
|
@ -1,7 +1,7 @@
|
|||
use super::*;
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
use super::*;
|
||||
use assert_approx_eq::assert_approx_eq;
|
||||
|
||||
fn simple_symmetric_tree() -> Tree<String, f64> {
|
||||
fn simple_symmetric_tree() -> Tree<String, f64> {
|
||||
let a = Alternative {
|
||||
name: "A".to_owned()
|
||||
};
|
||||
|
|
@ -18,9 +18,9 @@
|
|||
};
|
||||
let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b));
|
||||
Tree {root: root}
|
||||
}
|
||||
}
|
||||
|
||||
fn simple_asymmetric_tree() -> Tree<String, f64> {
|
||||
fn simple_asymmetric_tree() -> Tree<String, f64> {
|
||||
let a = Alternative {
|
||||
name: "A".to_owned()
|
||||
};
|
||||
|
|
@ -37,9 +37,9 @@
|
|||
};
|
||||
let root = Vertex::NonTerminal(Box::new(edge_a), Box::new(edge_b));
|
||||
Tree {root: root}
|
||||
}
|
||||
}
|
||||
|
||||
fn complex_tree() -> Tree<String, f64> {
|
||||
fn complex_tree() -> Tree<String, f64> {
|
||||
let a = Alternative {
|
||||
name: "A".to_owned()
|
||||
};
|
||||
|
|
@ -69,33 +69,33 @@
|
|||
};
|
||||
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() {
|
||||
// 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() {
|
||||
// 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() {
|
||||
// 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() {
|
||||
// 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();
|
||||
|
|
@ -103,10 +103,10 @@
|
|||
},
|
||||
simple_symmetric_tree()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parser_test_2() {
|
||||
#[test]
|
||||
fn parser_test_2() {
|
||||
assert_eq!(
|
||||
{
|
||||
let (_, b) = parser::subtree("([3.0]A[1.0]B)").unwrap();
|
||||
|
|
@ -114,10 +114,10 @@
|
|||
},
|
||||
simple_asymmetric_tree()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parser_test_3() {
|
||||
#[test]
|
||||
fn parser_test_3() {
|
||||
assert_eq!(
|
||||
{
|
||||
let (_, b) = parser::subtree("([0.5]([2.5]A[1.0]B)[1.0]C)").unwrap();
|
||||
|
|
@ -125,4 +125,4 @@
|
|||
},
|
||||
complex_tree()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue