#![allow(bad_style)] #![allow(clippy::float_cmp)] //! Mul by f32 rescales the object use hektor::*; #[test] fn Vec2_mul_f32() { let v1 = Vec2::new(1.0, 2.0); let f = 7.0; assert_eq!(v1 * f, Vec2::new(7.0, 14.0)); assert_eq!(f * v1, Vec2::new(7.0, 14.0)); } #[test] fn Vec2_mul_assign_f32() { let mut v1 = Vec2::new(1.0, 2.0); v1 *= 7.0; assert_eq!(v1, Vec2::new(1.0, 2.0) * 7.0); } #[test] fn Vec3_mul_f32() { let v1 = Vec3::new(1.0, 2.0, 3.0); let f = 7.0; assert_eq!(v1 * f, Vec3::new(7.0, 14.0, 21.0)); assert_eq!(f * v1, Vec3::new(7.0, 14.0, 21.0)); } #[test] fn Vec3_mul_assign_f32() { let mut v1 = Vec3::new(1.0, 2.0, 3.0); v1 *= 7.0; assert_eq!(v1, Vec3::new(7.0, 14.0, 21.0)); } #[test] fn Vec4_mul_f32() { let v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); let f = 7.0; assert_eq!(v1 * f, Vec4::new(7.0, 14.0, 21.0, 28.0)); assert_eq!(f * v1, Vec4::new(7.0, 14.0, 21.0, 28.0)); } #[test] fn Vec4_mul_assign_f32() { let mut v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); v1 *= 7.0; assert_eq!(v1, Vec4::new(7.0, 14.0, 21.0, 28.0)); } #[test] fn Mat2_mul_f32() { let m1_x = Vec2::new(1.0, 2.0); let m1_y = Vec2::new(3.0, 4.0); let m1 = Mat2::new(m1_x, m1_y); // let f = 7.0; // assert_eq!(m1 * f, Mat2::new(m1_x * f, m1_y * f)); assert_eq!(f * m1, Mat2::new(m1_x * f, m1_y * f)); } #[test] fn Mat2_mul_assign_f32() { let m1_x = Vec2::new(1.0, 2.0); let m1_y = Vec2::new(3.0, 4.0); let mut m1 = Mat2::new(m1_x, m1_y); // let f = 7.0; // m1 *= f; assert_eq!(m1, Mat2::new(m1_x * f, m1_y * f)); } #[test] fn Mat3_mul_f32() { let m1_x = Vec3::new(1.0, 2.0, 7.0); let m1_y = Vec3::new(3.0, 4.0, 8.0); let m1_z = Vec3::new(5.0, 6.0, 9.0); let m1 = Mat3::new(m1_x, m1_y, m1_z); // let f = 7.0; // assert_eq!(m1 * f, Mat3::new(m1_x * f, m1_y * f, m1_z * f)); assert_eq!(f * m1, Mat3::new(m1_x * f, m1_y * f, m1_z * f)); } #[test] fn Mat3_mul_assign_f32() { let m1_x = Vec3::new(1.0, 2.0, 7.0); let m1_y = Vec3::new(3.0, 4.0, 8.0); let m1_z = Vec3::new(5.0, 6.0, 9.0); let mut m1 = Mat3::new(m1_x, m1_y, m1_z); // let f = 7.0; // m1 *= f; assert_eq!(m1, Mat3::new(m1_x * f, m1_y * f, m1_z * f)); } #[test] fn Mat4_mul_f32() { let m1_x = Vec4::new(1.0, 2.0, 7.0, 12.0); let m1_y = Vec4::new(3.0, 4.0, 8.0, 1.5); let m1_z = Vec4::new(5.0, 6.0, 9.0, -80.0); let m1_w = Vec4::new(52.0, 63.0, 94.0, 67.0); let m1 = Mat4::new(m1_x, m1_y, m1_z, m1_w); // let f = 7.0; // assert_eq!(m1 * f, Mat4::new(m1_x * f, m1_y * f, m1_z * f, m1_w * f)); assert_eq!(f * m1, Mat4::new(m1_x * f, m1_y * f, m1_z * f, m1_w * f)); } #[test] fn Mat4_mul_assign_f32() { let m1_x = Vec4::new(1.0, 2.0, 7.0, 12.0); let m1_y = Vec4::new(3.0, 4.0, 8.0, 1.5); let m1_z = Vec4::new(5.0, 6.0, 9.0, -80.0); let m1_w = Vec4::new(52.0, 63.0, 94.0, 67.0); let mut m1 = Mat4::new(m1_x, m1_y, m1_z, m1_w); // let f = 7.0; // m1 *= f; assert_eq!(m1, Mat4::new(m1_x * f, m1_y * f, m1_z * f, m1_w * f)); }