#![allow(bad_style)] #![allow(clippy::float_cmp)] use hektor::*; #[test] fn Vec2_from_into_array() { let a: [f32; 2] = [1.0, 2.0]; assert_eq!(&format!("{:?}", Vec2::from(a)), "Vec2 { x: 1.0, y: 2.0 }"); let b: [f32; 2] = Vec2::from(a).into(); assert_eq!(a, b); } #[test] fn Vec3_from_into_array() { let a: [f32; 3] = [1.0, 2.0, 3.0]; assert_eq!( &format!("{:?}", Vec3::from(a)), "Vec3 { x: 1.0, y: 2.0, z: 3.0 }" ); let b: [f32; 3] = Vec3::from(a).into(); assert_eq!(a, b); } #[test] fn Vec4_from_into_array() { let a: [f32; 4] = [1.0, 2.0, 3.0, 4.0]; assert_eq!( &format!("{:?}", Vec4::from(a)), "Vec4 { x: 1.0, y: 2.0, z: 3.0, w: 4.0 }" ); let b: [f32; 4] = Vec4::from(a).into(); assert_eq!(a, b); } #[test] fn Mat2_from_into_array() { let a: [f32; 4] = [1.0, 2.0, 11.0, 12.0]; assert_eq!( &format!("{:?}", Mat2::from(a)), "Mat2 { x_axis: (1.0, 2.0), y_axis: (11.0, 12.0) }" ); let b: [f32; 4] = Mat2::from(a).into(); assert_eq!(a, b); // let m = Mat2::from([8.0, 5.0, 9.0, -1.0]); assert_eq!(m.x_axis().x(), 8.0); assert_eq!(m.x_axis().y(), 5.0); assert_eq!(m.y_axis().x(), 9.0); assert_eq!(m.y_axis().y(), -1.0); let arr: [f32; 4] = m.into(); assert_eq!(arr[0], 8.0); assert_eq!(arr[1], 5.0); assert_eq!(arr[2], 9.0); assert_eq!(arr[3], -1.0); } #[test] fn Mat3_from_into_array() { let a: [f32; 9] = [1.0, 2.0, 3.0, 11.0, 12.0, 13.0, 21.0, 22.0, 23.0]; assert_eq!( &format!("{:?}", Mat3::from(a)), "Mat3 { x_axis: (1.0, 2.0, 3.0), y_axis: (11.0, 12.0, 13.0), z_axis: (21.0, 22.0, 23.0) }" ); let b: [f32; 9] = Mat3::from(a).into(); assert_eq!(a, b); } #[test] fn Mat4_from_into_array() { let a: [f32; 16] = [ 1.0, 2.0, 3.0, 4.0, 11.0, 12.0, 13.0, 14.0, 21.0, 22.0, 23.0, 24.0, 31.0, 32.0, 33.0, 34.0, ]; assert_eq!( &format!("{:?}", Mat4::from(a)), "Mat4 { x_axis: (1.0, 2.0, 3.0, 4.0), y_axis: (11.0, 12.0, 13.0, 14.0), z_axis: (21.0, 22.0, 23.0, 24.0), w_axis: (31.0, 32.0, 33.0, 34.0) }" ); let b: [f32; 16] = Mat4::from(a).into(); assert_eq!(a, b); } #[test] fn Quat_from_into_array() { let a: [f32; 4] = [1.0, 2.0, 3.0, 4.0]; assert_eq!( &format!("{:?}", Quat::from(a)), "Quat { a: 1.0, b: 2.0, c: 3.0, d: 4.0 }" ); let b: [f32; 4] = Quat::from(a).into(); assert_eq!(a, b); }