Skip to content

Commit 729edc0

Browse files
committed
Add a few tests for MaybeOwnedMatrix
1 parent b370565 commit 729edc0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ndarray-linalg/src/eig.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,25 @@ where
203203
))
204204
}
205205
}
206+
207+
#[cfg(test)]
208+
mod tests {
209+
use crate::MaybeOwnedMatrix;
210+
211+
#[test]
212+
fn test_maybe_owned_matrix() {
213+
let a = array![[1.0, 2.0], [3.0, 4.0]];
214+
let a_ptr = a.as_ptr();
215+
let a1 = MaybeOwnedMatrix::into_owned(a);
216+
assert_eq!(a_ptr, a1.as_ptr());
217+
218+
let b = a1.clone();
219+
let b1 = MaybeOwnedMatrix::into_owned(&b);
220+
assert_eq!(b, b1);
221+
assert_ne!(b.as_ptr(), b1.as_ptr());
222+
223+
let b2 = MaybeOwnedMatrix::into_owned(&*b);
224+
assert_eq!(b, b2);
225+
assert_ne!(b.as_ptr(), b2.as_ptr());
226+
}
227+
}

0 commit comments

Comments
 (0)