fix tests

This commit is contained in:
Michael Sippel 2025-02-04 14:34:55 +01:00
parent 2f935ea3c2
commit de739a6e1a
Signed by: senvas
GPG key ID: F96CF119C34B64A6
2 changed files with 7 additions and 8 deletions

View file

@ -17,7 +17,7 @@ use {
pub struct SteinerTree {
weight: u64,
goals: Vec< TypeTerm >,
edges: Vec< MorphismType >,
pub edges: Vec< MorphismType >,
}
impl SteinerTree {

View file

@ -1,5 +1,5 @@
use {
crate::{dict::*, morphism::*, steiner_tree::*, TypeTerm}
crate::{dict::*, parser::*, unparser::*, morphism::*, steiner_tree::*, TypeTerm}
};
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>\\
@ -27,8 +27,8 @@ impl Morphism for DummyMorphism {
}
}
fn morphism_test_setup() -> ( TypeDict, MorphismBase<DummyMorphism> ) {
let mut dict = TypeDict::new();
fn morphism_test_setup() -> ( BimapTypeDict, MorphismBase<DummyMorphism> ) {
let mut dict = BimapTypeDict::new();
let mut base = MorphismBase::<DummyMorphism>::new( dict.add_typename("Seq".into()) );
dict.add_varname("Radix".into());
@ -118,7 +118,7 @@ fn test_morphism_path() {
Some((
DummyMorphism(MorphismType{
src_type: dict.parse("<Seq <Digit Radix> ~ Char>").unwrap(),
dst_type: dict.parse("<Seq <Digit Radix> ~ _2^64 ~ machine.UInt64>").unwrap()
dst_type: dict.parse("<Seq <Digit Radix> ~ _2^64 ~ machine.UInt64>").unwrap()
}),
dict.parse("Symbol ~ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>>").unwrap(),
@ -145,12 +145,12 @@ fn test_steiner_tree() {
// destination reprs
vec![
dict.parse(" ~ <PosInt 2 BigEndian> ~ <Seq <Digit 2> ~ Char>").unwrap(),
dict.parse(" ~ <PosInt 10 LittleEndian> ~ <Seq <Digit 10> ~ Char>").unwrap(),
dict.parse(" ~ <PosInt 10 LittleEndian> ~ <Seq <Digit 10> ~ Char>").unwrap(),
dict.parse(" ~ <PosInt 16 LittleEndian> ~ <Seq <Digit 16> ~ Char>").unwrap()
]
);
if let Some(solution) = steiner_tree_problem.solve_bfs( &dict, &base ) {
if let Some(solution) = steiner_tree_problem.solve_bfs( &base ) {
for e in solution.edges.iter() {
eprintln!(" :: {}\n--> {}", dict.unparse(&e.src_type), dict.unparse(&e.dst_type));
}
@ -158,4 +158,3 @@ fn test_steiner_tree() {
eprintln!("no solution");
}
}