test_neighbours.py 993 B

123456789101112131415161718192021222324252627282930
  1. '''
  2. Created on 25 nov. 2016
  3. @author: olinox
  4. '''
  5. import unittest
  6. from core import geometry
  7. from core.geometry import gneighbours
  8. class Test(unittest.TestCase):
  9. def test_neighbours_of(self):
  10. for coord in ( (0,0), (-10,-10), (10,10) ):
  11. x, y = coord
  12. self.assertEqual( gneighbours.neighbours_of(geometry.HEX, x, y), gneighbours.hex_neighbours_of(x, y) )
  13. self.assertEqual( gneighbours.neighbours_of(geometry.SQUARE, x, y), gneighbours.squ_neighbours_of(x, y) )
  14. def test_hex_neighbours_of(self):
  15. self.assertCountEqual( gneighbours.hex_neighbours_of(3,3), [(3,2), (4,3), (4,4), (3,4), (2,4), (2,3)] )
  16. self.assertCountEqual( gneighbours.hex_neighbours_of(4,4), [(4,3), (5,3), (5,4), (4,5), (3,4), (3,3)] )
  17. def test_squ_neighbours_of(self):
  18. self.assertCountEqual( gneighbours.squ_neighbours_of(3,3), [(2,3), (2,2), (3,2), (4,2), (4,3), (4,4), (3,4), (2,4)] )
  19. if __name__ == "__main__":
  20. unittest.main()