From e95f675e91c522d059139570691cff39348ac30f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 5 Sep 2024 16:53:30 -0700 Subject: [PATCH] test named fields --- fixed_wide_vectors/src/tests/mod.rs | 2 ++ fixed_wide_vectors/src/tests/named.rs | 30 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 fixed_wide_vectors/src/tests/named.rs diff --git a/fixed_wide_vectors/src/tests/mod.rs b/fixed_wide_vectors/src/tests/mod.rs index 67fb0b3..06e9ee5 100644 --- a/fixed_wide_vectors/src/tests/mod.rs +++ b/fixed_wide_vectors/src/tests/mod.rs @@ -1,5 +1,7 @@ mod tests; +#[cfg(feature="named-fields")] +mod named; #[cfg(feature="fixed_wide")] mod fixed_wide; diff --git a/fixed_wide_vectors/src/tests/named.rs b/fixed_wide_vectors/src/tests/named.rs new file mode 100644 index 0000000..04b0a08 --- /dev/null +++ b/fixed_wide_vectors/src/tests/named.rs @@ -0,0 +1,30 @@ +use crate::types::{Vector3,Matrix3}; + +#[test] +fn test_vector(){ + let mut v=Vector3::new([1,2,3]); + assert_eq!(v.x,1); + assert_eq!(v.y,2); + assert_eq!(v.z,3); + + v.x=5; + assert_eq!(v.x,5); + + v.y*=v.x; + assert_eq!(v.y,10); +} + + +#[test] +fn test_matrix(){ + let mut v=Matrix3::from_value(2); + assert_eq!(v.x_axis.x,2); + assert_eq!(v.y_axis.y,2); + assert_eq!(v.z_axis.z,2); + + v.x_axis.x=5; + assert_eq!(v.x_axis.x,5); + + v.y_axis.z*=v.x_axis.x; + assert_eq!(v.y_axis.z,10); +}