def test_returns_in_order(self): state = Zombie(8, 8) state.add_human(1, 1) state.add_human(2, 2) state.add_human(3, 3) iteration = 1 for each in state.humans(): self.assertEqual(each, (iteration, iteration)) iteration += 1 state.clear() state = Zombie(4, 4) state.add_zombie(1, 1) state.add_zombie(2, 2) state.add_zombie(3, 3) iteration = 1 for each in state.zombies(): self.assertEqual(each, (iteration, iteration)) iteration += 1
def test_states(self): state = Zombie(8, 6) state.clear() self.assertIs(type(state.num_zombies()), int) self.assertEqual(state.num_zombies(), 0) self.assertIs(type(state.num_humans()), int) self.assertEqual(state.num_humans(), 0) state.add_zombie(4, 4) self.assertEqual(state.num_zombies(), 1) state.add_human(4, 4) self.assertEqual(state.num_zombies(), 1) state.clear() self.assertEqual(state.num_zombies(), 0) self.assertEqual(state.num_humans(), 0) for dummy_row in range(state._grid_height): for dummy_col in range(state._grid_width): self.assertTrue(state.is_empty(dummy_row, dummy_col)) state.set_full(0, 0) self.assertFalse(state.is_empty(0, 0)) state.add_human(0, 1) state.add_human(1, 1) state.add_human(2, 1) state.add_human(3, 1) self.assertEqual(state.num_humans(), 4) state.clear() state = Zombie(10, 10) state.add_zombie(2, 3) self.assertTrue(state.zombies()) state.add_human(3, 2) self.assertTrue(state.humans())