From 1688707aed8e831cf8a2bc9bde8f41d83c88e0c9 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 17 Aug 2022 17:31:11 -0700 Subject: [PATCH] cross: backfill test for DimensionedSlice::IndexMut --- crates/cross/src/dim.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/cross/src/dim.rs b/crates/cross/src/dim.rs index bb4063d..a354a78 100644 --- a/crates/cross/src/dim.rs +++ b/crates/cross/src/dim.rs @@ -70,7 +70,7 @@ mod test { 3, 4, 5, 0, 10,20, - 10,40,50, + 30,40,50, ]; let s = DimensionedSlice::new(Vec3u::new(3, 2, 2), &data); assert_eq!(s[Vec3u::new(0, 0, 0)], 0); @@ -79,5 +79,27 @@ mod test { assert_eq!(s[Vec3u::new(1, 1, 1)], 40); assert_eq!(s[Vec3u::new(2, 1, 1)], 50); } + + #[test] + fn dimensioned_slice_index_mut() { + let mut data = [ + 0, 1, 2, + 3, 4, 5, + + 0, 10,20, + 30,40,50, + ]; + let mut s = DimensionedSlice::new(Vec3u::new(3, 2, 2), &mut data); + s[Vec3u::new(0, 0, 0)] = 100; + s[Vec3u::new(0, 1, 1)] = 300; + + assert_eq!(data, [ + 100,1, 2, + 3, 4, 5, + + 0, 10, 20, + 300,40,50, + ]); + } }