#![allow(bad_style)] #![allow(clippy::float_cmp)] #![allow(clippy::unnecessary_operation)] use hektor::*; #[test] fn Vec2_index_and_index_mut() { let mut v = Vec2::new(1.0, 2.0); assert_eq!(v[0], 1.0); assert_eq!(v[1], 2.0); v[0] = 0.0; assert_eq!(v[0], 0.0); v[1] = 0.0; assert_eq!(v[1], 0.0); } #[test] #[should_panic] fn Vec2_index_should_panic() { Vec2::default()[2]; } #[test] #[should_panic] fn Vec2_index_mut_should_panic() { Vec2::default()[2] = 0.0; } #[test] fn Vec3_index_and_index_mut() { let mut v = Vec3::new(1.0, 2.0, 3.0); assert_eq!(v[0], 1.0); assert_eq!(v[1], 2.0); assert_eq!(v[2], 3.0); v[0] = 0.0; assert_eq!(v[0], 0.0); v[1] = 0.0; assert_eq!(v[1], 0.0); v[2] = 0.0; assert_eq!(v[2], 0.0); } #[test] #[should_panic] fn Vec3_index_should_panic() { Vec3::default()[3]; } #[test] #[should_panic] fn Vec3_index_mut_should_panic() { Vec3::default()[3] = 0.0; } #[test] fn Vec4_index_and_index_mut() { let mut v = Vec4::new(1.0, 2.0, 3.0, 4.0); assert_eq!(v[0], 1.0); assert_eq!(v[1], 2.0); assert_eq!(v[2], 3.0); assert_eq!(v[3], 4.0); v[0] = 0.0; assert_eq!(v[0], 0.0); v[1] = 0.0; assert_eq!(v[1], 0.0); v[2] = 0.0; assert_eq!(v[2], 0.0); v[3] = 0.0; assert_eq!(v[3], 0.0); } #[test] #[should_panic] fn Vec4_index_should_panic() { Vec4::default()[4]; } #[test] #[should_panic] fn Vec4_index_mut_should_panic() { Vec4::default()[4] = 0.0; } #[test] fn Quat_index_and_index_mut() { let mut q = Quat::new(1.0, 2.0, 3.0, 4.0); assert_eq!(q[0], 1.0); assert_eq!(q[1], 2.0); assert_eq!(q[2], 3.0); assert_eq!(q[3], 4.0); q[0] = 0.0; assert_eq!(q[0], 0.0); q[1] = 0.0; assert_eq!(q[1], 0.0); q[2] = 0.0; assert_eq!(q[2], 0.0); q[3] = 0.0; assert_eq!(q[3], 0.0); } #[test] #[should_panic] fn Quat_index_should_panic() { Quat::default()[4]; } #[test] #[should_panic] fn Quat_index_mut_should_panic() { Quat::default()[4] = 0.0; } #[test] fn Mat2_index_and_index_mut() { let m_x = Vec2::new(1.0, 2.0); let m_y = Vec2::new(3.0, 4.0); let mut m = Mat2::new(m_x, m_y); assert_eq!(m[0], m_x); assert_eq!(m[1], m_y); m[0] = Vec2::default(); assert_eq!(m[0], Vec2::default()); m[1] = Vec2::default(); assert_eq!(m[1], Vec2::default()); } #[test] #[should_panic] fn Mat2_index_should_panic() { Mat2::default()[2]; } #[test] #[should_panic] fn Mat2_index_mut_should_panic() { Mat2::default()[2] = Vec2::default(); } #[test] fn Mat3_index_and_index_mut() { let m_x = Vec3::new(1.0, 2.0, 7.0); let m_y = Vec3::new(3.0, 4.0, 8.0); let m_z = Vec3::new(5.0, 6.0, 9.0); let mut m = Mat3::new(m_x, m_y, m_z); assert_eq!(m[0], m_x); assert_eq!(m[1], m_y); assert_eq!(m[2], m_z); m[0] = Vec3::default(); assert_eq!(m[0], Vec3::default()); m[1] = Vec3::default(); assert_eq!(m[1], Vec3::default()); m[2] = Vec3::default(); assert_eq!(m[2], Vec3::default()); } #[test] #[should_panic] fn Mat3_index_should_panic() { Mat3::default()[3]; } #[test] #[should_panic] fn Mat3_index_mut_should_panic() { Mat3::default()[3] = Vec3::default(); } #[test] fn Mat4_index_and_index_mut() { let m_x = Vec4::new(1.0, 2.0, 7.0, 12.0); let m_y = Vec4::new(3.0, 4.0, 8.0, 1.5); let m_z = Vec4::new(5.0, 6.0, 9.0, -80.0); let m_w = Vec4::new(52.0, 63.0, 94.0, 67.0); let mut m = Mat4::new(m_x, m_y, m_z, m_w); assert_eq!(m[0], m_x); assert_eq!(m[1], m_y); assert_eq!(m[2], m_z); assert_eq!(m[3], m_w); m[0] = Vec4::default(); assert_eq!(m[0], Vec4::default()); m[1] = Vec4::default(); assert_eq!(m[1], Vec4::default()); m[2] = Vec4::default(); assert_eq!(m[2], Vec4::default()); m[3] = Vec4::default(); assert_eq!(m[3], Vec4::default()); } #[test] #[should_panic] fn Mat4_index_should_panic() { Mat4::default()[4]; } #[test] #[should_panic] fn Mat4_index_mut_should_panic() { Mat4::default()[4] = Vec4::default(); }