fix: Tests had broken references

This commit is contained in:
Emilia Allison 2024-08-11 11:47:34 -04:00
parent 51093f5efd
commit c6d3b86237
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
1 changed files with 61 additions and 65 deletions

View File

@ -399,134 +399,130 @@ impl fmt::Display for TransferRegion {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use wasm_bindgen_test::*; use crate::plate::*;
use crate::transfer_region::*;
use crate::data::plate::*;
use crate::data::transfer_region::*;
#[test] #[test]
#[wasm_bindgen_test]
fn test_simple_transfer() { fn test_simple_transfer() {
let source = Plate::new(PlateType::Source, PlateFormat::W96); let source = Plate::new(PlateType::Source, PlateFormat::W96);
let destination = Plate::new(PlateType::Destination, PlateFormat::W384); let destination = Plate::new(PlateType::Destination, PlateFormat::W384);
let transfer1 = TransferRegion { let transfer1 = TransferRegion {
source_plate: source, source_plate: source,
source_region: Region::Rect((1, 1), (3, 3)), source_region: Region::Rect(Well{ row: 1, col: 1}, Well { row: 1, col: 1 }),
dest_plate: destination, dest_plate: destination,
dest_region: Region::Point((3, 3)), dest_region: Region::Point(Well {row: 3, col: 3}),
interleave_source: (1, 1), interleave_source: (1, 1),
interleave_dest: (1, 1), interleave_dest: (1, 1),
}; };
let transfer1_map = transfer1.calculate_map(); let transfer1_map = transfer1.calculate_map();
assert_eq!( assert_eq!(
transfer1_map((1, 1)), transfer1_map(Well {row: 1, col: 1}),
Some(vec! {(3,3)}), Some(vec! {Well {row: 3, col: 3}}),
"Failed basic shift transfer 1" "Failed basic shift transfer 1"
); );
assert_eq!( assert_eq!(
transfer1_map((1, 2)), transfer1_map(Well{ row: 1, col: 2}),
Some(vec! {(3,4)}), Some(vec! {Well{ row: 3, col: 4}}),
"Failed basic shift transfer 2" "Failed basic shift transfer 2"
); );
assert_eq!( assert_eq!(
transfer1_map((2, 2)), transfer1_map(Well{ row: 2, col: 2}),
Some(vec! {(4,4)}), Some(vec! {Well{ row: 4, col: 4}}),
"Failed basic shift transfer 3" "Failed basic shift transfer 3"
); );
let transfer2 = TransferRegion { let transfer2 = TransferRegion {
source_plate: source, source_plate: source,
source_region: Region::Rect((1, 1), (3, 3)), source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 3, col: 3}),
dest_plate: destination, dest_plate: destination,
dest_region: Region::Point((3, 3)), dest_region: Region::Point(Well{ row: 3, col: 3}),
interleave_source: (2, 2), interleave_source: (2, 2),
interleave_dest: (1, 1), interleave_dest: (1, 1),
}; };
let transfer2_map = transfer2.calculate_map(); let transfer2_map = transfer2.calculate_map();
assert_eq!( assert_eq!(
transfer2_map((1, 1)), transfer2_map(Well{ row: 1, col: 1}),
Some(vec! {(3,3)}), Some(vec! {Well{ row: 3, col: 3}}),
"Failed source interleave, type simple 1" "Failed source interleave, type simple 1"
); );
assert_eq!( assert_eq!(
transfer2_map((1, 2)), transfer2_map(Well{ row: 1, col: 2}),
None, None,
"Failed source interleave, type simple 2" "Failed source interleave, type simple 2"
); );
assert_eq!( assert_eq!(
transfer2_map((2, 2)), transfer2_map(Well{ row: 2, col: 2}),
None, None,
"Failed source interleave, type simple 3" "Failed source interleave, type simple 3"
); );
assert_eq!( assert_eq!(
transfer2_map((3, 3)), transfer2_map(Well{ row: 3, col: 3}),
Some(vec! {(4,4)}), Some(vec! {Well{ row: 4, col: 4}}),
"Failed source interleave, type simple 4" "Failed source interleave, type simple 4"
); );
let transfer3 = TransferRegion { let transfer3 = TransferRegion {
source_plate: source, source_plate: source,
source_region: Region::Rect((1, 1), (3, 3)), source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 3, col: 3}),
dest_plate: destination, dest_plate: destination,
dest_region: Region::Point((3, 3)), dest_region: Region::Point(Well{ row: 3, col: 3}),
interleave_source: (1, 1), interleave_source: (1, 1),
interleave_dest: (2, 3), interleave_dest: (2, 3),
}; };
let transfer3_map = transfer3.calculate_map(); let transfer3_map = transfer3.calculate_map();
assert_eq!( assert_eq!(
transfer3_map((1, 1)), transfer3_map(Well{ row: 1, col: 1}),
Some(vec! {(3,3)}), Some(vec! {Well{ row: 3, col: 3}}),
"Failed destination interleave, type simple 1" "Failed destination interleave, type simple 1"
); );
assert_eq!( assert_eq!(
transfer3_map((2, 1)), transfer3_map(Well{ row: 2, col: 1}),
Some(vec! {(5,3)}), Some(vec! {Well{ row: 5, col: 3}}),
"Failed destination interleave, type simple 2" "Failed destination interleave, type simple 2"
); );
assert_eq!( assert_eq!(
transfer3_map((1, 2)), transfer3_map(Well{ row: 1, col: 2}),
Some(vec! {(3,6)}), Some(vec! {Well{ row: 3, col: 6}}),
"Failed destination interleave, type simple 3" "Failed destination interleave, type simple 3"
); );
assert_eq!( assert_eq!(
transfer3_map((2, 2)), transfer3_map(Well{ row: 2, col: 2}),
Some(vec! {(5,6)}), Some(vec! {Well{ row: 5, col: 6}}),
"Failed destination interleave, type simple 4" "Failed destination interleave, type simple 4"
); );
} }
#[test] #[test]
#[wasm_bindgen_test]
fn test_replicate_transfer() { fn test_replicate_transfer() {
let source = Plate::new(PlateType::Source, PlateFormat::W96); let source = Plate::new(PlateType::Source, PlateFormat::W96);
let destination = Plate::new(PlateType::Destination, PlateFormat::W384); let destination = Plate::new(PlateType::Destination, PlateFormat::W384);
let transfer1 = TransferRegion { let transfer1 = TransferRegion {
source_plate: source, source_plate: source,
source_region: Region::Rect((1, 1), (2, 2)), source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 2, col: 2}),
dest_plate: destination, dest_plate: destination,
dest_region: Region::Rect((2, 2), (11, 11)), dest_region: Region::Rect(Well{ row: 2, col: 2}, Well{row:11, col:11}),
interleave_source: (1, 1), interleave_source: (1, 1),
interleave_dest: (3, 3), interleave_dest: (3, 3),
}; };
let transfer1_map = transfer1.calculate_map(); let transfer1_map = transfer1.calculate_map();
assert_eq!( assert_eq!(
transfer1_map((1, 1)), transfer1_map(Well{ row: 1, col: 1}),
Some(vec! {(2, 2), (2, 8), (8, 2), (8, 8)}), Some(vec! {Well{ row: 2, col: 2}, Well{ row: 2, col: 8}, Well{ row: 8, col: 2}, Well{ row: 8, col: 8}}),
"Failed type replicate 1" "Failed type replicate 1"
); );
assert_eq!( assert_eq!(
transfer1_map((2, 1)), transfer1_map(Well{ row: 2, col: 1}),
Some(vec! {(5, 2), (5, 8), (11, 2), (11, 8)}), Some(vec! {Well{ row: 5, col: 2}, Well{ row: 5, col: 8}, Well{ row: 11, col: 2}, Well{ row: 11, col: 8}}),
"Failed type replicate 1" "Failed type replicate 1"
); );
let transfer2 = TransferRegion { let transfer2 = TransferRegion {
source_plate: Plate::new(PlateType::Source, PlateFormat::W384), source_plate: Plate::new(PlateType::Source, PlateFormat::W384),
dest_plate: Plate::new(PlateType::Destination, PlateFormat::W384), dest_plate: Plate::new(PlateType::Destination, PlateFormat::W384),
source_region: Region::Rect((1, 1), (2, 3)), source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 2, col: 3}),
dest_region: Region::Rect((2, 2), (11, 16)), dest_region: Region::Rect(Well{ row: 2, col: 2}, Well{ row: 11, col: 16}),
interleave_source: (1, 1), interleave_source: (1, 1),
interleave_dest: (2, 2), interleave_dest: (2, 2),
}; };
@ -534,36 +530,36 @@ mod tests {
let transfer2_dest = transfer2.get_destination_wells(); let transfer2_dest = transfer2.get_destination_wells();
assert_eq!( assert_eq!(
transfer2_source, transfer2_source,
vec![(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)], vec![Well{ row: 1, col: 1}, Well{ row: 1, col: 2}, Well{ row: 1, col: 3}, Well{ row: 2, col: 1}, Well{ row: 2, col: 2}, Well{ row: 2, col: 3}],
"Failed type replicate 2 source" "Failed type replicate 2 source"
); );
assert_eq!( assert_eq!(
transfer2_dest, transfer2_dest,
vec![ vec![
(2, 2), Well{ row: 2, col: 2},
(2, 8), Well{ row: 2, col: 8},
(6, 2), Well{ row: 6, col: 2},
(6, 8), Well{ row: 6, col: 8},
(2, 4), Well{ row: 2, col: 4},
(2, 10), Well{ row: 2, col: 10},
(6, 4), Well{ row: 6, col: 4},
(6, 10), Well{ row: 6, col: 10},
(2, 6), Well{ row: 2, col: 6},
(2, 12), Well{ row: 2, col: 12},
(6, 6), Well{ row: 6, col: 6},
(6, 12), Well{ row: 6, col: 12},
(4, 2), Well{ row: 4, col: 2},
(4, 8), Well{ row: 4, col: 8},
(8, 2), Well{ row: 8, col: 2},
(8, 8), Well{ row: 8, col: 8},
(4, 4), Well{ row: 4, col: 4},
(4, 10), Well{ row: 4, col: 10},
(8, 4), Well{ row: 8, col: 4},
(8, 10), Well{ row: 8, col: 10},
(4, 6), Well{ row: 4, col: 6},
(4, 12), Well{ row: 4, col: 12},
(8, 6), Well{ row: 8, col: 6},
(8, 12) Well{ row: 8, col: 12}
], ],
"Failed type replicate 2 destination" "Failed type replicate 2 destination"
); );