Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Mubelotix committed Nov 12, 2023
1 parent 91acc40 commit c67a94d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions minecraft-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ fn test() {
let shape2 = shape1.clone() + Translation { x: -2.0, y: 0.0, z: 0.0 };
let translation = Translation { x: 2.0, y: 0.0, z: 0.0 };
assert_eq!(collide(&shape2, &translation, &shape1), Some(Translation { x: 1.0, y: 0.0, z: 0.0 }));

// From top
let shape2 = shape1.clone() + Translation { x: 0.0, y: 2.0, z: 0.0 };
let translation = Translation { x: 0.0, y: -2.0, z: 0.0 };
assert_eq!(collide(&shape2, &translation, &shape1), Some(Translation { x: 0.0, y: -1.0, z: 0.0 }));

// On last axis
let shape2 = shape1.clone() + Translation { x: 0.0, y: 0.0, z: 2.0 };
let translation = Translation { x: 0.0, y: 0.0, z: -2.0 };
assert_eq!(collide(&shape2, &translation, &shape1), Some(Translation { x: 0.0, y: 0.0, z: -1.0 }));
}

fn ray_cast(position: (f32, f32, f32), movement: (f32, f32, f32)) -> Vec<(isize, isize, isize)> {
Expand Down

0 comments on commit c67a94d

Please sign in to comment.