test_neighbours.py 935 B

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