Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Nov 11, 2024
1 parent 23ca972 commit b0c2ce1
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 5 deletions.
98 changes: 93 additions & 5 deletions swizzlegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,102 @@ fn write_test_loops(
E[e0], E[e1], E[e2], vec3t, V[e0], t, V[e1], t, V[e2], t,
)
})?;
if size == 4 {
// with_XXX swizzles
write_loops_vec3(out, size, |out, e0, e1, e2| {
if e0 == e1 || e0 == e2 || e1 == e2 {
return Ok(());
}
// The V used for the rhs. V shifted 1 to the right
let v_rhs = |i: usize| V[(i + 1) % size];
// Calculate the expected value for a position
let result = |pos: usize| {
// If any e matches this position the resulting value there should be from the rhs
if [e0, e1, e2].contains(&pos) {
return v_rhs(pos);
}
// Unchanged
V[pos]
};
writeln!(
out,
" assert_eq!(v.with_{}{}{}({}({}_{t}, {}_{t}, {}_{t})), {}({}_{t}, {}_{t}, {}_{t}, {}_{t}));",
E[e0],
E[e1],
E[e2],
vec3t,
v_rhs(e0),
v_rhs(e1),
v_rhs(e2),
vec4t,
result(0),
result(1),
result(2),
result(3),
t = t,
)
})?;
}
write_loops_vec2(out, size, |out, e0, e1| {
writeln!(
out,
" assert_eq!(v.{}{}(), {}({}_{}, {}_{}));",
E[e0], E[e1], vec2t, V[e0], t, V[e1], t,
)
})?;
if size >= 3 {
// with_XX swizzles
write_loops_vec2(out, size, |out, e0, e1| {
if e0 == e1 {
return Ok(());
}
// The V used for the rhs. V shifted 1 to the right
let v_rhs = |i: usize| V[(i + 1) % size];
// Calculate the expected value for a position
let result = |pos: usize| {
// If any e matches this position the resulting value there should be from the rhs
if [e0, e1].contains(&pos) {
return v_rhs(pos);
}
// Unchanged
V[pos]
};
write!(
out,
" assert_eq!(v.with_{}{}({}({}_{t}, {}_{t})), ",
E[e0],
E[e1],
vec2t,
v_rhs(e0),
v_rhs(e1),
t = t,
)?;
if size == 3 {
writeln!(
out,
"{}({}_{t}, {}_{t}, {}_{t}));",
vec3t,
result(0),
result(1),
result(2),
t = t,
)?;
} else {
writeln!(
out,
"{}({}_{t}, {}_{t}, {}_{t}, {}_{t}));",
vec4t,
result(0),
result(1),
result(2),
result(3),
t = t,
)?;
}

Ok(())
})?;
}
Ok(())
}

Expand All @@ -181,9 +270,9 @@ fn write_swizzle_tests_preamble(filename: &str) -> Result<impl Write> {
write_swizzle_head(&mut out)?;
writeln!(
&mut out,
r#"#[macro_use]
mod support;
use glam::*;"#
"#[macro_use]\n\
mod support;\n\
use glam::*;"
)?;
Ok(out)
}
Expand Down Expand Up @@ -223,6 +312,5 @@ fn main() -> Result<()> {
// Change into `./codegen` dir for convenience to the user
std::env::set_current_dir(env!("CARGO_MANIFEST_DIR"))?;

write_swizzle_tests()?;
Ok(())
write_swizzle_tests()
}
48 changes: 48 additions & 0 deletions tests/swizzles_f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ glam_test!(test_vec4_swizzles, {
assert_eq!(v.wwy(), vec3(4_f32, 4_f32, 2_f32));
assert_eq!(v.wwz(), vec3(4_f32, 4_f32, 3_f32));
assert_eq!(v.www(), vec3(4_f32, 4_f32, 4_f32));
assert_eq!(v.with_xyz(vec3(2_f32, 3_f32, 4_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_xyw(vec3(2_f32, 3_f32, 1_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_xzy(vec3(2_f32, 4_f32, 3_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_xzw(vec3(2_f32, 4_f32, 1_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_xwy(vec3(2_f32, 1_f32, 3_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_xwz(vec3(2_f32, 1_f32, 4_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_yxz(vec3(3_f32, 2_f32, 4_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_yxw(vec3(3_f32, 2_f32, 1_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_yzx(vec3(3_f32, 4_f32, 2_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_yzw(vec3(3_f32, 4_f32, 1_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.with_ywx(vec3(3_f32, 1_f32, 2_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_ywz(vec3(3_f32, 1_f32, 4_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.with_zxy(vec3(4_f32, 2_f32, 3_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_zxw(vec3(4_f32, 2_f32, 1_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_zyx(vec3(4_f32, 3_f32, 2_f32)), vec4(2_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_zyw(vec3(4_f32, 3_f32, 1_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.with_zwx(vec3(4_f32, 1_f32, 2_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_zwy(vec3(4_f32, 1_f32, 3_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.with_wxy(vec3(1_f32, 2_f32, 3_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_wxz(vec3(1_f32, 2_f32, 4_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_wyx(vec3(1_f32, 3_f32, 2_f32)), vec4(2_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_wyz(vec3(1_f32, 3_f32, 4_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.with_wzx(vec3(1_f32, 4_f32, 2_f32)), vec4(2_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_wzy(vec3(1_f32, 4_f32, 3_f32)), vec4(1_f32, 3_f32, 4_f32, 1_f32));
assert_eq!(v.xx(), vec2(1_f32, 1_f32));
assert_eq!(v.xy(), vec2(1_f32, 2_f32));
assert_eq!(v.xz(), vec2(1_f32, 3_f32));
Expand All @@ -341,6 +365,18 @@ glam_test!(test_vec4_swizzles, {
assert_eq!(v.wy(), vec2(4_f32, 2_f32));
assert_eq!(v.wz(), vec2(4_f32, 3_f32));
assert_eq!(v.ww(), vec2(4_f32, 4_f32));
assert_eq!(v.with_xy(vec2(2_f32, 3_f32)), vec4(2_f32, 3_f32, 3_f32, 4_f32));
assert_eq!(v.with_xz(vec2(2_f32, 4_f32)), vec4(2_f32, 2_f32, 4_f32, 4_f32));
assert_eq!(v.with_xw(vec2(2_f32, 1_f32)), vec4(2_f32, 2_f32, 3_f32, 1_f32));
assert_eq!(v.with_yx(vec2(3_f32, 2_f32)), vec4(2_f32, 3_f32, 3_f32, 4_f32));
assert_eq!(v.with_yz(vec2(3_f32, 4_f32)), vec4(1_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_yw(vec2(3_f32, 1_f32)), vec4(1_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_zx(vec2(4_f32, 2_f32)), vec4(2_f32, 2_f32, 4_f32, 4_f32));
assert_eq!(v.with_zy(vec2(4_f32, 3_f32)), vec4(1_f32, 3_f32, 4_f32, 4_f32));
assert_eq!(v.with_zw(vec2(4_f32, 1_f32)), vec4(1_f32, 2_f32, 4_f32, 1_f32));
assert_eq!(v.with_wx(vec2(1_f32, 2_f32)), vec4(2_f32, 2_f32, 3_f32, 1_f32));
assert_eq!(v.with_wy(vec2(1_f32, 3_f32)), vec4(1_f32, 3_f32, 3_f32, 1_f32));
assert_eq!(v.with_wz(vec2(1_f32, 4_f32)), vec4(1_f32, 2_f32, 4_f32, 1_f32));
});

glam_test!(test_vec3a_swizzles, {
Expand Down Expand Up @@ -462,6 +498,12 @@ glam_test!(test_vec3a_swizzles, {
assert_eq!(v.zx(), vec2(3_f32, 1_f32));
assert_eq!(v.zy(), vec2(3_f32, 2_f32));
assert_eq!(v.zz(), vec2(3_f32, 3_f32));
assert_eq!(v.with_xy(vec2(2_f32, 3_f32)), vec3a(2_f32, 3_f32, 3_f32));
assert_eq!(v.with_xz(vec2(2_f32, 1_f32)), vec3a(2_f32, 2_f32, 1_f32));
assert_eq!(v.with_yx(vec2(3_f32, 2_f32)), vec3a(2_f32, 3_f32, 3_f32));
assert_eq!(v.with_yz(vec2(3_f32, 1_f32)), vec3a(1_f32, 3_f32, 1_f32));
assert_eq!(v.with_zx(vec2(1_f32, 2_f32)), vec3a(2_f32, 2_f32, 1_f32));
assert_eq!(v.with_zy(vec2(1_f32, 3_f32)), vec3a(1_f32, 3_f32, 1_f32));
});

glam_test!(test_vec3_swizzles, {
Expand Down Expand Up @@ -583,6 +625,12 @@ glam_test!(test_vec3_swizzles, {
assert_eq!(v.zx(), vec2(3_f32, 1_f32));
assert_eq!(v.zy(), vec2(3_f32, 2_f32));
assert_eq!(v.zz(), vec2(3_f32, 3_f32));
assert_eq!(v.with_xy(vec2(2_f32, 3_f32)), vec3(2_f32, 3_f32, 3_f32));
assert_eq!(v.with_xz(vec2(2_f32, 1_f32)), vec3(2_f32, 2_f32, 1_f32));
assert_eq!(v.with_yx(vec2(3_f32, 2_f32)), vec3(2_f32, 3_f32, 3_f32));
assert_eq!(v.with_yz(vec2(3_f32, 1_f32)), vec3(1_f32, 3_f32, 1_f32));
assert_eq!(v.with_zx(vec2(1_f32, 2_f32)), vec3(2_f32, 2_f32, 1_f32));
assert_eq!(v.with_zy(vec2(1_f32, 3_f32)), vec3(1_f32, 3_f32, 1_f32));
});

glam_test!(test_vec2_swizzles, {
Expand Down
42 changes: 42 additions & 0 deletions tests/swizzles_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ glam_test!(test_dvec4_swizzles, {
assert_eq!(v.wwy(), dvec3(4_f64, 4_f64, 2_f64));
assert_eq!(v.wwz(), dvec3(4_f64, 4_f64, 3_f64));
assert_eq!(v.www(), dvec3(4_f64, 4_f64, 4_f64));
assert_eq!(v.with_xyz(dvec3(2_f64, 3_f64, 4_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_xyw(dvec3(2_f64, 3_f64, 1_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_xzy(dvec3(2_f64, 4_f64, 3_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_xzw(dvec3(2_f64, 4_f64, 1_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_xwy(dvec3(2_f64, 1_f64, 3_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_xwz(dvec3(2_f64, 1_f64, 4_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_yxz(dvec3(3_f64, 2_f64, 4_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_yxw(dvec3(3_f64, 2_f64, 1_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_yzx(dvec3(3_f64, 4_f64, 2_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_yzw(dvec3(3_f64, 4_f64, 1_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.with_ywx(dvec3(3_f64, 1_f64, 2_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_ywz(dvec3(3_f64, 1_f64, 4_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.with_zxy(dvec3(4_f64, 2_f64, 3_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_zxw(dvec3(4_f64, 2_f64, 1_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_zyx(dvec3(4_f64, 3_f64, 2_f64)), dvec4(2_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_zyw(dvec3(4_f64, 3_f64, 1_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.with_zwx(dvec3(4_f64, 1_f64, 2_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_zwy(dvec3(4_f64, 1_f64, 3_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.with_wxy(dvec3(1_f64, 2_f64, 3_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_wxz(dvec3(1_f64, 2_f64, 4_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_wyx(dvec3(1_f64, 3_f64, 2_f64)), dvec4(2_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_wyz(dvec3(1_f64, 3_f64, 4_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.with_wzx(dvec3(1_f64, 4_f64, 2_f64)), dvec4(2_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_wzy(dvec3(1_f64, 4_f64, 3_f64)), dvec4(1_f64, 3_f64, 4_f64, 1_f64));
assert_eq!(v.xx(), dvec2(1_f64, 1_f64));
assert_eq!(v.xy(), dvec2(1_f64, 2_f64));
assert_eq!(v.xz(), dvec2(1_f64, 3_f64));
Expand All @@ -341,6 +365,18 @@ glam_test!(test_dvec4_swizzles, {
assert_eq!(v.wy(), dvec2(4_f64, 2_f64));
assert_eq!(v.wz(), dvec2(4_f64, 3_f64));
assert_eq!(v.ww(), dvec2(4_f64, 4_f64));
assert_eq!(v.with_xy(dvec2(2_f64, 3_f64)), dvec4(2_f64, 3_f64, 3_f64, 4_f64));
assert_eq!(v.with_xz(dvec2(2_f64, 4_f64)), dvec4(2_f64, 2_f64, 4_f64, 4_f64));
assert_eq!(v.with_xw(dvec2(2_f64, 1_f64)), dvec4(2_f64, 2_f64, 3_f64, 1_f64));
assert_eq!(v.with_yx(dvec2(3_f64, 2_f64)), dvec4(2_f64, 3_f64, 3_f64, 4_f64));
assert_eq!(v.with_yz(dvec2(3_f64, 4_f64)), dvec4(1_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_yw(dvec2(3_f64, 1_f64)), dvec4(1_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_zx(dvec2(4_f64, 2_f64)), dvec4(2_f64, 2_f64, 4_f64, 4_f64));
assert_eq!(v.with_zy(dvec2(4_f64, 3_f64)), dvec4(1_f64, 3_f64, 4_f64, 4_f64));
assert_eq!(v.with_zw(dvec2(4_f64, 1_f64)), dvec4(1_f64, 2_f64, 4_f64, 1_f64));
assert_eq!(v.with_wx(dvec2(1_f64, 2_f64)), dvec4(2_f64, 2_f64, 3_f64, 1_f64));
assert_eq!(v.with_wy(dvec2(1_f64, 3_f64)), dvec4(1_f64, 3_f64, 3_f64, 1_f64));
assert_eq!(v.with_wz(dvec2(1_f64, 4_f64)), dvec4(1_f64, 2_f64, 4_f64, 1_f64));
});

glam_test!(test_dvec3_swizzles, {
Expand Down Expand Up @@ -462,6 +498,12 @@ glam_test!(test_dvec3_swizzles, {
assert_eq!(v.zx(), dvec2(3_f64, 1_f64));
assert_eq!(v.zy(), dvec2(3_f64, 2_f64));
assert_eq!(v.zz(), dvec2(3_f64, 3_f64));
assert_eq!(v.with_xy(dvec2(2_f64, 3_f64)), dvec3(2_f64, 3_f64, 3_f64));
assert_eq!(v.with_xz(dvec2(2_f64, 1_f64)), dvec3(2_f64, 2_f64, 1_f64));
assert_eq!(v.with_yx(dvec2(3_f64, 2_f64)), dvec3(2_f64, 3_f64, 3_f64));
assert_eq!(v.with_yz(dvec2(3_f64, 1_f64)), dvec3(1_f64, 3_f64, 1_f64));
assert_eq!(v.with_zx(dvec2(1_f64, 2_f64)), dvec3(2_f64, 2_f64, 1_f64));
assert_eq!(v.with_zy(dvec2(1_f64, 3_f64)), dvec3(1_f64, 3_f64, 1_f64));
});

glam_test!(test_dvec2_swizzles, {
Expand Down
42 changes: 42 additions & 0 deletions tests/swizzles_i16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,30 @@ glam_test!(test_i16vec4_swizzles, {
assert_eq!(v.wwy(), i16vec3(4_i16, 4_i16, 2_i16));
assert_eq!(v.wwz(), i16vec3(4_i16, 4_i16, 3_i16));
assert_eq!(v.www(), i16vec3(4_i16, 4_i16, 4_i16));
assert_eq!(v.with_xyz(i16vec3(2_i16, 3_i16, 4_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_xyw(i16vec3(2_i16, 3_i16, 1_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_xzy(i16vec3(2_i16, 4_i16, 3_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_xzw(i16vec3(2_i16, 4_i16, 1_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_xwy(i16vec3(2_i16, 1_i16, 3_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_xwz(i16vec3(2_i16, 1_i16, 4_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_yxz(i16vec3(3_i16, 2_i16, 4_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_yxw(i16vec3(3_i16, 2_i16, 1_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_yzx(i16vec3(3_i16, 4_i16, 2_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_yzw(i16vec3(3_i16, 4_i16, 1_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.with_ywx(i16vec3(3_i16, 1_i16, 2_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_ywz(i16vec3(3_i16, 1_i16, 4_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.with_zxy(i16vec3(4_i16, 2_i16, 3_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_zxw(i16vec3(4_i16, 2_i16, 1_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_zyx(i16vec3(4_i16, 3_i16, 2_i16)), i16vec4(2_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_zyw(i16vec3(4_i16, 3_i16, 1_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.with_zwx(i16vec3(4_i16, 1_i16, 2_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_zwy(i16vec3(4_i16, 1_i16, 3_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.with_wxy(i16vec3(1_i16, 2_i16, 3_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_wxz(i16vec3(1_i16, 2_i16, 4_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_wyx(i16vec3(1_i16, 3_i16, 2_i16)), i16vec4(2_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_wyz(i16vec3(1_i16, 3_i16, 4_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.with_wzx(i16vec3(1_i16, 4_i16, 2_i16)), i16vec4(2_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_wzy(i16vec3(1_i16, 4_i16, 3_i16)), i16vec4(1_i16, 3_i16, 4_i16, 1_i16));
assert_eq!(v.xx(), i16vec2(1_i16, 1_i16));
assert_eq!(v.xy(), i16vec2(1_i16, 2_i16));
assert_eq!(v.xz(), i16vec2(1_i16, 3_i16));
Expand All @@ -341,6 +365,18 @@ glam_test!(test_i16vec4_swizzles, {
assert_eq!(v.wy(), i16vec2(4_i16, 2_i16));
assert_eq!(v.wz(), i16vec2(4_i16, 3_i16));
assert_eq!(v.ww(), i16vec2(4_i16, 4_i16));
assert_eq!(v.with_xy(i16vec2(2_i16, 3_i16)), i16vec4(2_i16, 3_i16, 3_i16, 4_i16));
assert_eq!(v.with_xz(i16vec2(2_i16, 4_i16)), i16vec4(2_i16, 2_i16, 4_i16, 4_i16));
assert_eq!(v.with_xw(i16vec2(2_i16, 1_i16)), i16vec4(2_i16, 2_i16, 3_i16, 1_i16));
assert_eq!(v.with_yx(i16vec2(3_i16, 2_i16)), i16vec4(2_i16, 3_i16, 3_i16, 4_i16));
assert_eq!(v.with_yz(i16vec2(3_i16, 4_i16)), i16vec4(1_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_yw(i16vec2(3_i16, 1_i16)), i16vec4(1_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_zx(i16vec2(4_i16, 2_i16)), i16vec4(2_i16, 2_i16, 4_i16, 4_i16));
assert_eq!(v.with_zy(i16vec2(4_i16, 3_i16)), i16vec4(1_i16, 3_i16, 4_i16, 4_i16));
assert_eq!(v.with_zw(i16vec2(4_i16, 1_i16)), i16vec4(1_i16, 2_i16, 4_i16, 1_i16));
assert_eq!(v.with_wx(i16vec2(1_i16, 2_i16)), i16vec4(2_i16, 2_i16, 3_i16, 1_i16));
assert_eq!(v.with_wy(i16vec2(1_i16, 3_i16)), i16vec4(1_i16, 3_i16, 3_i16, 1_i16));
assert_eq!(v.with_wz(i16vec2(1_i16, 4_i16)), i16vec4(1_i16, 2_i16, 4_i16, 1_i16));
});

glam_test!(test_i16vec3_swizzles, {
Expand Down Expand Up @@ -462,6 +498,12 @@ glam_test!(test_i16vec3_swizzles, {
assert_eq!(v.zx(), i16vec2(3_i16, 1_i16));
assert_eq!(v.zy(), i16vec2(3_i16, 2_i16));
assert_eq!(v.zz(), i16vec2(3_i16, 3_i16));
assert_eq!(v.with_xy(i16vec2(2_i16, 3_i16)), i16vec3(2_i16, 3_i16, 3_i16));
assert_eq!(v.with_xz(i16vec2(2_i16, 1_i16)), i16vec3(2_i16, 2_i16, 1_i16));
assert_eq!(v.with_yx(i16vec2(3_i16, 2_i16)), i16vec3(2_i16, 3_i16, 3_i16));
assert_eq!(v.with_yz(i16vec2(3_i16, 1_i16)), i16vec3(1_i16, 3_i16, 1_i16));
assert_eq!(v.with_zx(i16vec2(1_i16, 2_i16)), i16vec3(2_i16, 2_i16, 1_i16));
assert_eq!(v.with_zy(i16vec2(1_i16, 3_i16)), i16vec3(1_i16, 3_i16, 1_i16));
});

glam_test!(test_i16vec2_swizzles, {
Expand Down
Loading

0 comments on commit b0c2ce1

Please sign in to comment.