From 0ae29f4bc010c5c747e57c78e977c0f77d5fd83f Mon Sep 17 00:00:00 2001 From: Thilo Behnke Date: Sun, 1 May 2022 18:35:33 +0200 Subject: [PATCH] fix tests --- pong/tests/collision_handler_test.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pong/tests/collision_handler_test.rs b/pong/tests/collision_handler_test.rs index ea452a8..dc83f58 100644 --- a/pong/tests/collision_handler_test.rs +++ b/pong/tests/collision_handler_test.rs @@ -5,6 +5,8 @@ use pong::geom::geom::Vector; use pong::geom::shape::Shape; use rstest::rstest; use std::borrow::{Borrow, BorrowMut}; +use std::cell::RefCell; +use std::rc::Rc; #[rstest] #[case( @@ -64,14 +66,14 @@ use std::borrow::{Borrow, BorrowMut}; create_game_obj(2, Vector::new(0., 0.), Vector::new(0., 1.), true), )] pub fn should_handle_collision( - #[case] mut obj_a: Box, - #[case] mut obj_b: Box, - #[case] expected_a: Box, - #[case] expected_b: Box, + #[case] mut obj_a: Rc>>, + #[case] mut obj_b: Rc>>, + #[case] expected_a: Rc>>, + #[case] expected_b: Rc>>, ) { let mut handler = CollisionHandler::new(); handler.register((String::from("obj"), String::from("obj")), |a, b| {}); - let res = handler.handle(&mut obj_a, &mut obj_b); + let res = handler.handle(obj_a, obj_b); assert_eq!(true, res) // assert_eq!(obj_a.pos(), expected_a.pos()); // assert_eq!(obj_a.vel(), expected_a.vel()); @@ -84,8 +86,8 @@ fn create_game_obj( vel: Vector, orientation: Vector, is_static: bool, -) -> Box { - Box::new(DefaultGameObject::new( +) -> Rc>> { + Rc::new(RefCell::new(Box::new(DefaultGameObject::new( id, "obj".to_string(), Box::new(DefaultGeomComp::new(Shape::rect( @@ -95,5 +97,5 @@ fn create_game_obj( 20., ))), Box::new(DefaultPhysicsComp::new(vel, is_static)), - )) + )))) }