screen tests
This commit is contained in:
@@ -35,6 +35,29 @@ impl Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_in_bounds() {
|
||||||
|
let x = 20;
|
||||||
|
let y = 20;
|
||||||
|
let s = Screen::new(x, y);
|
||||||
|
|
||||||
|
assert!(&s.is_in_bounds(&Point(0, 0)));
|
||||||
|
assert!(!&s.is_in_bounds(&Point(21, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_valid_movements_board() {
|
||||||
|
let x = 20;
|
||||||
|
let y = 20;
|
||||||
|
let s = Screen::new(x, y);
|
||||||
|
|
||||||
|
let valid = s.get_valid_movements(&Point(0,0));
|
||||||
|
assert_eq!(valid, Point(0,0).get_neighbors());
|
||||||
|
|
||||||
|
let border = s.get_valid_movements(&Point(19,19));
|
||||||
|
assert!(border.len() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
pub enum BoardCommand {
|
pub enum BoardCommand {
|
||||||
Dig(Point),
|
Dig(Point),
|
||||||
LayEgg(Point, u32),
|
LayEgg(Point, u32),
|
||||||
|
|||||||
-20
@@ -29,24 +29,6 @@ fn render(e: &Entities, w: &World, b: &Screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
// TODO: tests, cleanup code in general
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn board() {
|
|
||||||
let max_x = 20;
|
|
||||||
let max_y = 20;
|
|
||||||
|
|
||||||
let mut board = Screen::new(max_x, max_y);
|
|
||||||
let mut world = World::new();
|
|
||||||
|
|
||||||
dbg!(board.is_in_bounds(&Point(0, 0)));
|
|
||||||
dbg!(board.get_valid_movements(&Point(0, 0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn simulate(e: &mut Entities, w: &mut World, b: &mut Screen) {
|
fn simulate(e: &mut Entities, w: &mut World, b: &mut Screen) {
|
||||||
let cmds: Vec<BoardCommand> = e
|
let cmds: Vec<BoardCommand> = e
|
||||||
.data
|
.data
|
||||||
@@ -90,8 +72,6 @@ fn main() {
|
|||||||
|
|
||||||
getmaxyx(stdscr(), &mut max_y, &mut max_x);
|
getmaxyx(stdscr(), &mut max_y, &mut max_x);
|
||||||
|
|
||||||
// TODO: fix renderable to render different colors
|
|
||||||
|
|
||||||
let mut board = Screen::new(max_x, max_y);
|
let mut board = Screen::new(max_x, max_y);
|
||||||
let mut world = World::new();
|
let mut world = World::new();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user