fix: Tests had broken references
This commit is contained in:
parent
51093f5efd
commit
c6d3b86237
|
@ -399,134 +399,130 @@ impl fmt::Display for TransferRegion {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
use crate::data::plate::*;
|
||||
use crate::data::transfer_region::*;
|
||||
use crate::plate::*;
|
||||
use crate::transfer_region::*;
|
||||
|
||||
#[test]
|
||||
#[wasm_bindgen_test]
|
||||
fn test_simple_transfer() {
|
||||
let source = Plate::new(PlateType::Source, PlateFormat::W96);
|
||||
let destination = Plate::new(PlateType::Destination, PlateFormat::W384);
|
||||
|
||||
let transfer1 = TransferRegion {
|
||||
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_region: Region::Point((3, 3)),
|
||||
dest_region: Region::Point(Well {row: 3, col: 3}),
|
||||
interleave_source: (1, 1),
|
||||
interleave_dest: (1, 1),
|
||||
};
|
||||
let transfer1_map = transfer1.calculate_map();
|
||||
assert_eq!(
|
||||
transfer1_map((1, 1)),
|
||||
Some(vec! {(3,3)}),
|
||||
transfer1_map(Well {row: 1, col: 1}),
|
||||
Some(vec! {Well {row: 3, col: 3}}),
|
||||
"Failed basic shift transfer 1"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer1_map((1, 2)),
|
||||
Some(vec! {(3,4)}),
|
||||
transfer1_map(Well{ row: 1, col: 2}),
|
||||
Some(vec! {Well{ row: 3, col: 4}}),
|
||||
"Failed basic shift transfer 2"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer1_map((2, 2)),
|
||||
Some(vec! {(4,4)}),
|
||||
transfer1_map(Well{ row: 2, col: 2}),
|
||||
Some(vec! {Well{ row: 4, col: 4}}),
|
||||
"Failed basic shift transfer 3"
|
||||
);
|
||||
|
||||
let transfer2 = TransferRegion {
|
||||
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_region: Region::Point((3, 3)),
|
||||
dest_region: Region::Point(Well{ row: 3, col: 3}),
|
||||
interleave_source: (2, 2),
|
||||
interleave_dest: (1, 1),
|
||||
};
|
||||
let transfer2_map = transfer2.calculate_map();
|
||||
assert_eq!(
|
||||
transfer2_map((1, 1)),
|
||||
Some(vec! {(3,3)}),
|
||||
transfer2_map(Well{ row: 1, col: 1}),
|
||||
Some(vec! {Well{ row: 3, col: 3}}),
|
||||
"Failed source interleave, type simple 1"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer2_map((1, 2)),
|
||||
transfer2_map(Well{ row: 1, col: 2}),
|
||||
None,
|
||||
"Failed source interleave, type simple 2"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer2_map((2, 2)),
|
||||
transfer2_map(Well{ row: 2, col: 2}),
|
||||
None,
|
||||
"Failed source interleave, type simple 3"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer2_map((3, 3)),
|
||||
Some(vec! {(4,4)}),
|
||||
transfer2_map(Well{ row: 3, col: 3}),
|
||||
Some(vec! {Well{ row: 4, col: 4}}),
|
||||
"Failed source interleave, type simple 4"
|
||||
);
|
||||
|
||||
let transfer3 = TransferRegion {
|
||||
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_region: Region::Point((3, 3)),
|
||||
dest_region: Region::Point(Well{ row: 3, col: 3}),
|
||||
interleave_source: (1, 1),
|
||||
interleave_dest: (2, 3),
|
||||
};
|
||||
let transfer3_map = transfer3.calculate_map();
|
||||
assert_eq!(
|
||||
transfer3_map((1, 1)),
|
||||
Some(vec! {(3,3)}),
|
||||
transfer3_map(Well{ row: 1, col: 1}),
|
||||
Some(vec! {Well{ row: 3, col: 3}}),
|
||||
"Failed destination interleave, type simple 1"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer3_map((2, 1)),
|
||||
Some(vec! {(5,3)}),
|
||||
transfer3_map(Well{ row: 2, col: 1}),
|
||||
Some(vec! {Well{ row: 5, col: 3}}),
|
||||
"Failed destination interleave, type simple 2"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer3_map((1, 2)),
|
||||
Some(vec! {(3,6)}),
|
||||
transfer3_map(Well{ row: 1, col: 2}),
|
||||
Some(vec! {Well{ row: 3, col: 6}}),
|
||||
"Failed destination interleave, type simple 3"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer3_map((2, 2)),
|
||||
Some(vec! {(5,6)}),
|
||||
transfer3_map(Well{ row: 2, col: 2}),
|
||||
Some(vec! {Well{ row: 5, col: 6}}),
|
||||
"Failed destination interleave, type simple 4"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[wasm_bindgen_test]
|
||||
fn test_replicate_transfer() {
|
||||
let source = Plate::new(PlateType::Source, PlateFormat::W96);
|
||||
let destination = Plate::new(PlateType::Destination, PlateFormat::W384);
|
||||
|
||||
let transfer1 = TransferRegion {
|
||||
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_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_dest: (3, 3),
|
||||
};
|
||||
let transfer1_map = transfer1.calculate_map();
|
||||
assert_eq!(
|
||||
transfer1_map((1, 1)),
|
||||
Some(vec! {(2, 2), (2, 8), (8, 2), (8, 8)}),
|
||||
transfer1_map(Well{ row: 1, col: 1}),
|
||||
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"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer1_map((2, 1)),
|
||||
Some(vec! {(5, 2), (5, 8), (11, 2), (11, 8)}),
|
||||
transfer1_map(Well{ row: 2, col: 1}),
|
||||
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"
|
||||
);
|
||||
|
||||
let transfer2 = TransferRegion {
|
||||
source_plate: Plate::new(PlateType::Source, PlateFormat::W384),
|
||||
dest_plate: Plate::new(PlateType::Destination, PlateFormat::W384),
|
||||
source_region: Region::Rect((1, 1), (2, 3)),
|
||||
dest_region: Region::Rect((2, 2), (11, 16)),
|
||||
source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 2, col: 3}),
|
||||
dest_region: Region::Rect(Well{ row: 2, col: 2}, Well{ row: 11, col: 16}),
|
||||
interleave_source: (1, 1),
|
||||
interleave_dest: (2, 2),
|
||||
};
|
||||
|
@ -534,36 +530,36 @@ mod tests {
|
|||
let transfer2_dest = transfer2.get_destination_wells();
|
||||
assert_eq!(
|
||||
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"
|
||||
);
|
||||
assert_eq!(
|
||||
transfer2_dest,
|
||||
vec![
|
||||
(2, 2),
|
||||
(2, 8),
|
||||
(6, 2),
|
||||
(6, 8),
|
||||
(2, 4),
|
||||
(2, 10),
|
||||
(6, 4),
|
||||
(6, 10),
|
||||
(2, 6),
|
||||
(2, 12),
|
||||
(6, 6),
|
||||
(6, 12),
|
||||
(4, 2),
|
||||
(4, 8),
|
||||
(8, 2),
|
||||
(8, 8),
|
||||
(4, 4),
|
||||
(4, 10),
|
||||
(8, 4),
|
||||
(8, 10),
|
||||
(4, 6),
|
||||
(4, 12),
|
||||
(8, 6),
|
||||
(8, 12)
|
||||
Well{ row: 2, col: 2},
|
||||
Well{ row: 2, col: 8},
|
||||
Well{ row: 6, col: 2},
|
||||
Well{ row: 6, col: 8},
|
||||
Well{ row: 2, col: 4},
|
||||
Well{ row: 2, col: 10},
|
||||
Well{ row: 6, col: 4},
|
||||
Well{ row: 6, col: 10},
|
||||
Well{ row: 2, col: 6},
|
||||
Well{ row: 2, col: 12},
|
||||
Well{ row: 6, col: 6},
|
||||
Well{ row: 6, col: 12},
|
||||
Well{ row: 4, col: 2},
|
||||
Well{ row: 4, col: 8},
|
||||
Well{ row: 8, col: 2},
|
||||
Well{ row: 8, col: 8},
|
||||
Well{ row: 4, col: 4},
|
||||
Well{ row: 4, col: 10},
|
||||
Well{ row: 8, col: 4},
|
||||
Well{ row: 8, col: 10},
|
||||
Well{ row: 4, col: 6},
|
||||
Well{ row: 4, col: 12},
|
||||
Well{ row: 8, col: 6},
|
||||
Well{ row: 8, col: 12}
|
||||
],
|
||||
"Failed type replicate 2 destination"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue