more tests

This commit is contained in:
2023-12-07 10:12:44 +01:00
parent 7b0eaf6640
commit e47036bd8d
7 changed files with 129 additions and 28 deletions

View File

@@ -76,13 +76,13 @@ fn test_change_life() {
max_life: 10,
gold: 0,
};
assert_eq!(p.life, 5);
assert_eq!(p.get_life(), 5);
p.change_life(-2);
assert_eq!(p.life, 3);
assert_eq!(p.get_life(), 3);
p.change_life(10);
assert_eq!(p.life, 10);
assert_eq!(p.get_life(), 10);
p.change_life(-12);
assert_eq!(p.life, 0);
assert_eq!(p.get_life(), 0);
}
#[test]
@@ -96,4 +96,17 @@ fn player_can_move() {
p.get_position().set(1, 2, 3);
p.get_position().change(2, 1);
assert_eq!(p.get_position(), &Position::new(1, 4, 4));
assert_eq!(p.get_immutable_position(), &Position::new(1, 4, 4));
}
#[test]
fn test_max_life() {
let p = Player {
name: "Teddy Tester".to_string(),
position: Position::new(0, 1, 1),
life: 5,
max_life: 10,
gold: 0,
};
assert_eq!(p.get_max_life(), 10);
}