#[cfg(test)]
mod test {
    use crate::{
        Affine2, Affine3, Affine3A, Mat2, Mat3, Mat3A, Mat4, Quat, Vec2, Vec3, Vec3A, Vec4,
    };
    #[cfg(feature = "f64")]
    use crate::{DAffine2, DAffine3, DMat2, DMat3, DMat4, DQuat, DVec2, DVec3, DVec4};
    #[cfg(feature = "i16")]
    use crate::{I16Vec2, I16Vec3, I16Vec4};
    #[cfg(feature = "i64")]
    use crate::{I64Vec2, I64Vec3, I64Vec4};
    #[cfg(feature = "i8")]
    use crate::{I8Vec2, I8Vec3, I8Vec4};
    #[cfg(feature = "i32")]
    use crate::{IVec2, IVec3, IVec4};
    #[cfg(feature = "u16")]
    use crate::{U16Vec2, U16Vec3, U16Vec4};
    #[cfg(feature = "u64")]
    use crate::{U64Vec2, U64Vec3, U64Vec4};
    #[cfg(feature = "u8")]
    use crate::{U8Vec2, U8Vec3, U8Vec4};
    #[cfg(feature = "u32")]
    use crate::{UVec2, UVec3, UVec4};
    use core::mem;

    macro_rules! test_into_bytes_t {
        ($name:ident, $t:ty) => {
            #[test]
            fn $name() {
                let t = <$t>::default();
                let b = zerocopy::IntoBytes::as_bytes(&t);
                // the below loop will fail in miri if we're doing something bad here.
                for bi in b {
                    assert_eq!(bi, bi);
                }
                // should be the same address
                assert_eq!(&t as *const $t as usize, b.as_ptr() as usize);
                // should be the same size
                assert_eq!(b.len(), mem::size_of_val(&t));
            }
        };
    }

    macro_rules! test_from_bytes_t {
        ($name:ident, $t:ident) => {
            #[test]
            fn $name() {
                let b = [0_u8; mem::size_of::<$t>()];
                let t = zerocopy::FromBytes::read_from_bytes(&b);
                // should be the same size
                let t: $t = t.unwrap();
                // should be zero
                assert_eq!(t, <$t as zerocopy::FromZeros>::new_zeroed());
            }
        };
    }

    test_from_bytes_t!(affine2_from, Affine2);
    test_from_bytes_t!(affine3_from, Affine3);
    test_into_bytes_t!(affine3_into, Affine3);
    test_from_bytes_t!(affine3a_from, Affine3A);
    #[cfg(all(
        any(
            target_arch = "aarch64",
            target_feature = "sse2",
            target_feature = "simd128"
        ),
        not(feature = "scalar-math")
    ))]
    test_into_bytes_t!(affine3a_into, Affine3A);
    test_from_bytes_t!(mat2_from, Mat2);
    test_into_bytes_t!(mat2_into, Mat2);
    test_from_bytes_t!(mat3_from, Mat3);
    test_into_bytes_t!(mat3_into, Mat3);
    test_from_bytes_t!(mat3a_from, Mat3A);
    #[cfg(all(
        any(
            feature = "core-simd",
            target_arch = "aarch64",
            target_feature = "sse2",
            target_feature = "simd128"
        ),
        not(feature = "scalar-math")
    ))]
    test_into_bytes_t!(mat3a_into, Mat3A);
    test_from_bytes_t!(mat4_from, Mat4);
    test_into_bytes_t!(mat4_into, Mat4);
    test_from_bytes_t!(quat_from, Quat);
    test_into_bytes_t!(quat_into, Quat);
    test_from_bytes_t!(vec2_from, Vec2);
    test_into_bytes_t!(vec2_into, Vec2);
    test_from_bytes_t!(vec3_from, Vec3);
    test_into_bytes_t!(vec3_into, Vec3);
    test_from_bytes_t!(vec3a_from, Vec3A);
    #[cfg(all(
        any(
            feature = "core-simd",
            target_arch = "aarch64",
            target_feature = "sse2",
            target_feature = "simd128"
        ),
        not(feature = "scalar-math")
    ))]
    test_into_bytes_t!(vec3a_into, Vec3A);
    test_from_bytes_t!(vec4_from, Vec4);
    test_into_bytes_t!(vec4_into, Vec4);

    #[cfg(feature = "f64")]
    test_from_bytes_t!(daffine2_from, DAffine2);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(daffine2_into, DAffine2);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(daffine3_from, DAffine3);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(daffine3_into, DAffine3);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dmat2_from, DMat2);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dmat2_into, DMat2);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dmat3_from, DMat3);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dmat3_into, DMat3);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dmat4_from, DMat4);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dmat4_into, DMat4);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dquat_from, DQuat);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dquat_into, DQuat);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dvec2_from, DVec2);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dvec2_into, DVec2);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dvec3_from, DVec3);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dvec3_into, DVec3);
    #[cfg(feature = "f64")]
    test_from_bytes_t!(dvec4_from, DVec4);
    #[cfg(feature = "f64")]
    test_into_bytes_t!(dvec4_into, DVec4);

    #[cfg(feature = "i8")]
    test_from_bytes_t!(i8vec2_from, I8Vec2);
    #[cfg(feature = "i8")]
    test_into_bytes_t!(i8vec2_into, I8Vec2);
    #[cfg(feature = "i8")]
    test_from_bytes_t!(i8vec3_from, I8Vec3);
    #[cfg(feature = "i8")]
    test_into_bytes_t!(i8vec3_into, I8Vec3);
    #[cfg(feature = "i8")]
    test_from_bytes_t!(i8vec4_from, I8Vec4);
    #[cfg(feature = "i8")]
    test_into_bytes_t!(i8vec4_into, I8Vec4);

    #[cfg(feature = "u8")]
    test_from_bytes_t!(u8vec2_from, U8Vec2);
    #[cfg(feature = "u8")]
    test_into_bytes_t!(u8vec2_into, U8Vec2);
    #[cfg(feature = "u8")]
    test_from_bytes_t!(u8vec3_from, U8Vec3);
    #[cfg(feature = "u8")]
    test_into_bytes_t!(u8vec3_into, U8Vec3);
    #[cfg(feature = "u8")]
    test_from_bytes_t!(u8vec4_from, U8Vec4);
    #[cfg(feature = "u8")]
    test_into_bytes_t!(u8vec4_into, U8Vec4);

    #[cfg(feature = "i16")]
    test_from_bytes_t!(i16vec2_from, I16Vec2);
    #[cfg(feature = "i16")]
    test_into_bytes_t!(i16vec2_into, I16Vec2);
    #[cfg(feature = "i16")]
    test_from_bytes_t!(i16vec3_from, I16Vec3);
    #[cfg(feature = "i16")]
    test_into_bytes_t!(i16vec3_into, I16Vec3);
    #[cfg(feature = "i16")]
    test_from_bytes_t!(i16vec4_from, I16Vec4);
    #[cfg(feature = "i16")]
    test_into_bytes_t!(i16vec4_into, I16Vec4);

    #[cfg(feature = "u16")]
    test_from_bytes_t!(u16vec2_from, U16Vec2);
    #[cfg(feature = "u16")]
    test_into_bytes_t!(u16vec2_into, U16Vec2);
    #[cfg(feature = "u16")]
    test_from_bytes_t!(u16vec3_from, U16Vec3);
    #[cfg(feature = "u16")]
    test_into_bytes_t!(u16vec3_into, U16Vec3);
    #[cfg(feature = "u16")]
    test_from_bytes_t!(u16vec4_from, U16Vec4);
    #[cfg(feature = "u16")]
    test_into_bytes_t!(u16vec4_into, U16Vec4);

    #[cfg(feature = "i32")]
    test_from_bytes_t!(ivec2_from, IVec2);
    #[cfg(feature = "i32")]
    test_into_bytes_t!(ivec2_into, IVec2);
    #[cfg(feature = "i32")]
    test_from_bytes_t!(ivec3_from, IVec3);
    #[cfg(feature = "i32")]
    test_into_bytes_t!(ivec3_into, IVec3);
    #[cfg(feature = "i32")]
    test_from_bytes_t!(ivec4_from, IVec4);
    #[cfg(feature = "i32")]
    test_into_bytes_t!(ivec4_into, IVec4);

    #[cfg(feature = "u32")]
    test_from_bytes_t!(uvec2_from, UVec2);
    #[cfg(feature = "u32")]
    test_into_bytes_t!(uvec2_into, UVec2);
    #[cfg(feature = "u32")]
    test_from_bytes_t!(uvec3_from, UVec3);
    #[cfg(feature = "u32")]
    test_into_bytes_t!(uvec3_into, UVec3);
    #[cfg(feature = "u32")]
    test_from_bytes_t!(uvec4_from, UVec4);
    #[cfg(feature = "u32")]
    test_into_bytes_t!(uvec4_into, UVec4);

    #[cfg(feature = "i64")]
    test_from_bytes_t!(i64vec2_from, I64Vec2);
    #[cfg(feature = "i64")]
    test_into_bytes_t!(i64vec2_into, I64Vec2);
    #[cfg(feature = "i64")]
    test_from_bytes_t!(i64vec3_from, I64Vec3);
    #[cfg(feature = "i64")]
    test_into_bytes_t!(i64vec3_into, I64Vec3);
    #[cfg(feature = "i64")]
    test_from_bytes_t!(i64vec4_from, I64Vec4);
    #[cfg(feature = "i64")]
    test_into_bytes_t!(i64vec4_into, I64Vec4);

    #[cfg(feature = "u64")]
    test_from_bytes_t!(u64vec2_from, U64Vec2);
    #[cfg(feature = "u64")]
    test_into_bytes_t!(u64vec2_into, U64Vec2);
    #[cfg(feature = "u64")]
    test_from_bytes_t!(u64vec3_from, U64Vec3);
    #[cfg(feature = "u64")]
    test_into_bytes_t!(u64vec3_into, U64Vec3);
    #[cfg(feature = "u64")]
    test_from_bytes_t!(u64vec4_from, U64Vec4);
    #[cfg(feature = "u64")]
    test_into_bytes_t!(u64vec4_into, U64Vec4);
}
