mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-11 02:08:01 -06:00
chore: solve tests/ clippy warnings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use pacman::constants::RAW_BOARD;
|
||||
use pacman::map::Map;
|
||||
use pacman::map::builder::Map;
|
||||
|
||||
mod collision;
|
||||
mod item;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use glam::Vec2;
|
||||
use pacman::constants::{CELL_SIZE, RAW_BOARD};
|
||||
use pacman::map::Map;
|
||||
use pacman::map::builder::Map;
|
||||
use sdl2::render::Texture;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2,7 +2,6 @@ use pacman::entity::direction::Direction;
|
||||
use pacman::entity::graph::{Graph, Node};
|
||||
use pacman::entity::pacman::Pacman;
|
||||
use pacman::texture::sprite::{AtlasMapper, MapperFrame, SpriteAtlas};
|
||||
use sdl2::keyboard::Keycode;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn create_test_graph() -> Graph {
|
||||
@@ -72,36 +71,3 @@ fn test_pacman_creation() {
|
||||
assert!(pacman.traverser.position.is_at_node());
|
||||
assert_eq!(pacman.traverser.direction, Direction::Left);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pacman_key_handling() {
|
||||
let graph = create_test_graph();
|
||||
let atlas = create_test_atlas();
|
||||
let mut pacman = Pacman::new(&graph, 0, &atlas).unwrap();
|
||||
|
||||
let test_cases = [
|
||||
(Keycode::Up, Direction::Up),
|
||||
(Keycode::Down, Direction::Down),
|
||||
(Keycode::Left, Direction::Left),
|
||||
(Keycode::Right, Direction::Right),
|
||||
];
|
||||
|
||||
for (key, expected_direction) in test_cases {
|
||||
pacman.handle_key(key);
|
||||
assert!(pacman.traverser.next_direction.is_some() || pacman.traverser.direction == expected_direction);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pacman_invalid_key() {
|
||||
let graph = create_test_graph();
|
||||
let atlas = create_test_atlas();
|
||||
let mut pacman = Pacman::new(&graph, 0, &atlas).unwrap();
|
||||
|
||||
let original_direction = pacman.traverser.direction;
|
||||
let original_next_direction = pacman.traverser.next_direction;
|
||||
|
||||
pacman.handle_key(Keycode::Space);
|
||||
assert_eq!(pacman.traverser.direction, original_direction);
|
||||
assert_eq!(pacman.traverser.next_direction, original_next_direction);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user