Skip to content

Commit

Permalink
Add test for Negate
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 15, 2024
1 parent 2bf7db3 commit 96a7f60
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/input_context/input_modifier/negate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ impl Negate {

impl Default for Negate {
fn default() -> Self {
Self {
x: true,
y: true,
z: true,
}
Self::all(true)
}
}

Expand All @@ -76,3 +72,30 @@ impl InputModifier for Negate {
ActionValue::Axis3D(negated).convert(value.dim())
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn negation() {
let world = World::new();

assert_eq!(
Negate::default().apply(&world, 0.0, Vec3::ONE.into()),
ActionValue::Axis3D(Vec3::NEG_ONE)
);
assert_eq!(
Negate::x(true).apply(&world, 0.0, Vec3::ONE.into()),
ActionValue::Axis3D(Vec3::new(-1.0, 1.0, 1.0))
);
assert_eq!(
Negate::y(true).apply(&world, 0.0, Vec3::ONE.into()),
ActionValue::Axis3D(Vec3::new(1.0, -1.0, 1.0))
);
assert_eq!(
Negate::z(true).apply(&world, 0.0, Vec3::ONE.into()),
ActionValue::Axis3D(Vec3::new(1.0, 1.0, -1.0))
);
}
}

0 comments on commit 96a7f60

Please sign in to comment.