#![allow(bad_style)] #![allow(clippy::float_cmp)] use hektor::*; #[test] fn Vec2_sub_Vec2() { let v1 = Vec2::new(1.0, 2.0); let v2 = Vec2::new(8.0, -6.5); assert_eq!(v1 - v2, Vec2::new(-7.0, 8.5)); } #[test] fn Vec2_sub_assign_Vec2() { let mut v1 = Vec2::new(1.0, 2.0); v1 -= Vec2::new(8.0, -6.5); assert_eq!(v1, Vec2::new(-7.0, 8.5)); } #[test] fn Vec2_sub_f32() { let v1 = Vec2::new(1.0, 2.0); let f = 7.0; assert_eq!(v1 - f, v1 - Vec2::splat(f)); assert_eq!(f - v1, Vec2::splat(f) - v1); } #[test] fn Vec2_sub_assign_f32() { let mut v1 = Vec2::new(1.0, 2.0); v1 -= 7.0; assert_eq!(v1, Vec2::new(1.0, 2.0) - Vec2::splat(7.0)); } #[test] fn Vec3_sub_Vec3() { let v1 = Vec3::new(1.0, 2.0, 3.0); let v2 = Vec3::new(8.0, -6.5, 7.0); assert_eq!(v1 - v2, Vec3::new(-7.0, 8.5, -4.0)); } #[test] fn Vec3_sub_assign_Vec3() { let mut v1 = Vec3::new(1.0, 2.0, 3.0); v1 -= Vec3::new(8.0, -6.5, 7.0); assert_eq!(v1, Vec3::new(-7.0, 8.5, -4.0)); } #[test] fn Vec3_sub_f32() { let v1 = Vec3::new(1.0, 2.0, 3.0); let f = 7.0; assert_eq!(v1 - f, v1 - Vec3::splat(f)); assert_eq!(f - v1, Vec3::splat(f) - v1); } #[test] fn Vec3_sub_assign_f32() { let mut v1 = Vec3::new(1.0, 2.0, 3.0); v1 -= 7.0; assert_eq!(v1, Vec3::new(1.0, 2.0, 3.0) - Vec3::splat(7.0)); } #[test] fn Vec4_sub_Vec4() { let v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); let v2 = Vec4::new(8.0, -6.5, 7.0, 0.0); assert_eq!(v1 - v2, Vec4::new(-7.0, 8.5, -4.0, 4.0)); } #[test] fn Vec4_sub_assign_Vec4() { let mut v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); v1 -= Vec4::new(8.0, -6.5, 7.0, 0.0); assert_eq!(v1, Vec4::new(-7.0, 8.5, -4.0, 4.0)); } #[test] fn Vec4_sub_f32() { let v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); let f = 7.0; assert_eq!(v1 - f, v1 - Vec4::splat(f)); assert_eq!(f - v1, Vec4::splat(f) - v1); } #[test] fn Vec4_sub_assign_f32() { let mut v1 = Vec4::new(1.0, 2.0, 3.0, 4.0); v1 -= 7.0; assert_eq!(v1, Vec4::new(1.0, 2.0, 3.0, 4.0) - Vec4::splat(7.0)); } #[test] fn Mat2_sub_Mat2() { 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 m2_x = Vec2::new(12.0, 6.0); let m2_y = Vec2::new(-10.0, 20.0); let m2 = Mat2::new(m2_x, m2_y); // assert_eq!(m1 - m2, Mat2::new(m1_x - m2_x, m1_y - m2_y)); } #[test] fn Mat2_sub_assign_Mat2() { 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 m2_x = Vec2::new(12.0, 6.0); let m2_y = Vec2::new(-10.0, 20.0); let m2 = Mat2::new(m2_x, m2_y); // m1 -= m2; assert_eq!(m1, Mat2::new(m1_x - m2_x, m1_y - m2_y)); } #[test] fn Mat2_sub_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, m1 - Mat2::splat(f)); assert_eq!(f - m1, Mat2::splat(f) - m1); } #[test] fn Mat2_sub_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, m1_y) - Mat2::splat(f)); } #[test] fn Mat3_sub_Mat3() { 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 m2_x = Vec3::new(12.0, 6.0, 8.0); let m2_y = Vec3::new(-10.0, 20.0, 0.0); let m2_z = Vec3::new(-12.0, 22.0, 15.0); let m2 = Mat3::new(m2_x, m2_y, m2_z); // assert_eq!(m1 - m2, Mat3::new(m1_x - m2_x, m1_y - m2_y, m1_z - m2_z)); } #[test] fn Mat3_sub_assign_Mat3() { 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 m2_x = Vec3::new(12.0, 6.0, 8.0); let m2_y = Vec3::new(-10.0, 20.0, 0.0); let m2_z = Vec3::new(-12.0, 22.0, 15.0); let m2 = Mat3::new(m2_x, m2_y, m2_z); // m1 -= m2; assert_eq!(m1, Mat3::new(m1_x - m2_x, m1_y - m2_y, m1_z - m2_z)); } #[test] fn Mat3_sub_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, m1 - Mat3::splat(f)); assert_eq!(f - m1, Mat3::splat(f) - m1); } #[test] fn Mat3_sub_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, m1_y, m1_z) - Mat3::splat(f)); } #[test] fn Mat4_sub_Mat4() { 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 m2_x = Vec4::new(12.0, 6.0, 8.0, 10.5); let m2_y = Vec4::new(-10.0, 20.0, 0.0, 9.5); let m2_z = Vec4::new(-12.0, 22.0, 15.0, 8.5); let m2_w = Vec4::new(-1.0, 2.0, 5.0, 7.5); let m2 = Mat4::new(m2_x, m2_y, m2_z, m2_w); // assert_eq!( m1 - m2, Mat4::new(m1_x - m2_x, m1_y - m2_y, m1_z - m2_z, m1_w - m2_w) ); } #[test] fn Mat4_sub_assign_Mat4() { 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 m2_x = Vec4::new(12.0, 6.0, 8.0, 10.5); let m2_y = Vec4::new(-10.0, 20.0, 0.0, 9.5); let m2_z = Vec4::new(-12.0, 22.0, 15.0, 8.5); let m2_w = Vec4::new(-1.0, 2.0, 5.0, 7.5); let m2 = Mat4::new(m2_x, m2_y, m2_z, m2_w); // m1 -= m2; assert_eq!( m1, Mat4::new(m1_x - m2_x, m1_y - m2_y, m1_z - m2_z, m1_w - m2_w) ); } #[test] fn Mat4_sub_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, m1 - Mat4::splat(f)); assert_eq!(f - m1, Mat4::splat(f) - m1); } #[test] fn Mat4_sub_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, m1_y, m1_z, m1_w) - Mat4::splat(f)); }