Skip to content

Commit

Permalink
Add tests for bvec constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitshifter committed Jul 7, 2024
1 parent 8531717 commit e2e86ae
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 74 deletions.
53 changes: 30 additions & 23 deletions tests/vec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod support;

macro_rules! impl_vec2_tests {
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident) => {
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $masknew:ident) => {
glam_test!(test_const, {
const V0: $vec2 = $vec2::splat(1 as $t);
const V1: $vec2 = $vec2::new(1 as $t, 2 as $t);
Expand Down Expand Up @@ -269,6 +269,13 @@ macro_rules! impl_vec2_tests {
assert!(b.cmpeq($vec2::splat(1 as $t)).all());
});

glam_test!(test_mask_new, {
assert_eq!($mask::new(false, false), $masknew(false, false));
assert_eq!($mask::new(true, false), $masknew(true, false));
assert_eq!($mask::new(false, true), $masknew(false, true));
assert_eq!($mask::new(true, true), $masknew(true, true));
});

glam_test!(test_mask_from_array_bool, {
assert_eq!($mask::new(false, false), $mask::from([false, false]));
assert_eq!($mask::new(true, false), $mask::from([true, false]));
Expand Down Expand Up @@ -522,8 +529,8 @@ macro_rules! impl_vec2_tests {
}

macro_rules! impl_vec2_signed_tests {
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident) => {
impl_vec2_tests!($t, $new, $vec2, $vec3, $mask);
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $masknew:ident) => {
impl_vec2_tests!($t, $new, $vec2, $vec3, $mask, $masknew);

glam_test!(test_is_negative_bitmask, {
assert_eq!($vec2::ZERO.is_negative_bitmask(), 0b00);
Expand Down Expand Up @@ -606,8 +613,8 @@ macro_rules! impl_vec2_signed_tests {
}

macro_rules! impl_vec2_signed_integer_tests {
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident) => {
impl_vec2_signed_tests!($t, $new, $vec2, $vec3, $mask);
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $masknew:ident) => {
impl_vec2_signed_tests!($t, $new, $vec2, $vec3, $mask, $masknew);

glam_test!(test_signum, {
assert_eq!($vec3::ZERO.signum(), $vec3::ZERO);
Expand Down Expand Up @@ -649,8 +656,8 @@ macro_rules! impl_vec2_eq_hash_tests {
}

macro_rules! impl_vec2_float_tests {
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident) => {
impl_vec2_signed_tests!($t, $new, $vec2, $vec3, $mask);
($t:ident, $new:ident, $vec2:ident, $vec3:ident, $mask:ident, $masknew:ident) => {
impl_vec2_signed_tests!($t, $new, $vec2, $vec3, $mask, $masknew);
impl_vec_float_normalize_tests!($t, $vec2);

glam_test!(test_vec2_nan, {
Expand Down Expand Up @@ -1154,7 +1161,7 @@ macro_rules! impl_vec2_bit_op_tests {
}

mod vec2 {
use glam::{vec2, BVec2, Vec2, Vec3};
use glam::{bvec2, vec2, BVec2, Vec2, Vec3};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1234,11 +1241,11 @@ mod vec2 {
assert_eq!(I64Vec2::new(1, 2), U64Vec2::new(1, 2).as_i64vec2());
});

impl_vec2_float_tests!(f32, vec2, Vec2, Vec3, BVec2);
impl_vec2_float_tests!(f32, vec2, Vec2, Vec3, BVec2, bvec2);
}

mod dvec2 {
use glam::{dvec2, BVec2, DVec2, DVec3, IVec2, UVec2, Vec2};
use glam::{bvec2, dvec2, BVec2, DVec2, DVec3, IVec2, UVec2, Vec2};

glam_test!(test_align, {
use core::mem;
Expand All @@ -1257,11 +1264,11 @@ mod dvec2 {
assert_eq!(DVec2::new(1.0, 2.0), DVec2::from(UVec2::new(1, 2)));
});

impl_vec2_float_tests!(f64, dvec2, DVec2, DVec3, BVec2);
impl_vec2_float_tests!(f64, dvec2, DVec2, DVec3, BVec2, bvec2);
}

mod i16vec2 {
use glam::{i16vec2, BVec2, I16Vec2, I16Vec3, I64Vec2, IVec2, U16Vec2, U64Vec2, UVec2};
use glam::{bvec2, i16vec2, BVec2, I16Vec2, I16Vec3, I64Vec2, IVec2, U16Vec2, U64Vec2, UVec2};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1393,7 +1400,7 @@ mod i16vec2 {
);
});

impl_vec2_signed_integer_tests!(i16, i16vec2, I16Vec2, I16Vec3, BVec2);
impl_vec2_signed_integer_tests!(i16, i16vec2, I16Vec2, I16Vec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(i16, i16vec2);

impl_vec2_scalar_shift_op_tests!(I16Vec2, -2, 2);
Expand All @@ -1404,7 +1411,7 @@ mod i16vec2 {
}

mod u16vec2 {
use glam::{u16vec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U16Vec3, U64Vec2, UVec2};
use glam::{bvec2, u16vec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U16Vec3, U64Vec2, UVec2};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1528,7 +1535,7 @@ mod u16vec2 {
);
});

impl_vec2_tests!(u16, u16vec2, U16Vec2, U16Vec3, BVec2);
impl_vec2_tests!(u16, u16vec2, U16Vec2, U16Vec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(u16, u16vec2);

impl_vec2_scalar_shift_op_tests!(U16Vec2, 0, 2);
Expand All @@ -1539,7 +1546,7 @@ mod u16vec2 {
}

mod ivec2 {
use glam::{ivec2, BVec2, I16Vec2, I64Vec2, IVec2, IVec3, U16Vec2, U64Vec2, UVec2};
use glam::{bvec2, ivec2, BVec2, I16Vec2, I64Vec2, IVec2, IVec3, U16Vec2, U64Vec2, UVec2};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1659,7 +1666,7 @@ mod ivec2 {
);
});

impl_vec2_signed_integer_tests!(i32, ivec2, IVec2, IVec3, BVec2);
impl_vec2_signed_integer_tests!(i32, ivec2, IVec2, IVec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(i32, ivec2);

impl_vec2_scalar_shift_op_tests!(IVec2, -2, 2);
Expand All @@ -1670,7 +1677,7 @@ mod ivec2 {
}

mod uvec2 {
use glam::{uvec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U64Vec2, UVec2, UVec3};
use glam::{bvec2, uvec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U64Vec2, UVec2, UVec3};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1785,7 +1792,7 @@ mod uvec2 {
);
});

impl_vec2_tests!(u32, uvec2, UVec2, UVec3, BVec2);
impl_vec2_tests!(u32, uvec2, UVec2, UVec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(u32, uvec2);

impl_vec2_scalar_shift_op_tests!(UVec2, 0, 2);
Expand All @@ -1796,7 +1803,7 @@ mod uvec2 {
}

mod i64vec2 {
use glam::{i64vec2, BVec2, I16Vec2, I64Vec2, I64Vec3, IVec2, U16Vec2, U64Vec2, UVec2};
use glam::{bvec2, i64vec2, BVec2, I16Vec2, I64Vec2, I64Vec3, IVec2, U16Vec2, U64Vec2, UVec2};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1851,7 +1858,7 @@ mod i64vec2 {
);
});

impl_vec2_signed_integer_tests!(i64, i64vec2, I64Vec2, I64Vec3, BVec2);
impl_vec2_signed_integer_tests!(i64, i64vec2, I64Vec2, I64Vec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(i64, i64vec2);

impl_vec2_scalar_shift_op_tests!(I64Vec2, -2, 2);
Expand All @@ -1862,7 +1869,7 @@ mod i64vec2 {
}

mod u64vec2 {
use glam::{u64vec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U64Vec2, U64Vec3, UVec2};
use glam::{bvec2, u64vec2, BVec2, I16Vec2, I64Vec2, IVec2, U16Vec2, U64Vec2, U64Vec3, UVec2};

glam_test!(test_align, {
use core::mem;
Expand Down Expand Up @@ -1916,7 +1923,7 @@ mod u64vec2 {
);
});

impl_vec2_tests!(u64, u64vec2, U64Vec2, U64Vec3, BVec2);
impl_vec2_tests!(u64, u64vec2, U64Vec2, U64Vec3, BVec2, bvec2);
impl_vec2_eq_hash_tests!(u64, u64vec2);

impl_vec2_scalar_shift_op_tests!(U64Vec2, 0, 2);
Expand Down
Loading

0 comments on commit e2e86ae

Please sign in to comment.