test_triangle.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. '''
  2. Created on 22 nov. 2016
  3. @author: olinox
  4. '''
  5. import unittest
  6. from pypog import geometry
  7. class Test(unittest.TestCase):
  8. """test triangle algorithms"""
  9. def test_sq_triangle(self):
  10. """test triangle algorithms on square grid"""
  11. grid_shape = geometry.SQUARE
  12. for i in geometry.ANGLES:
  13. self.assertCountEqual(geometry.triangle(grid_shape, 0, 0, 0, 0, i), [(0,0)])
  14. #TODO: complete
  15. def test_hex_triangle(self):
  16. """test triangle algorithms on hexagonal grid"""
  17. grid_shape = geometry.HEX
  18. for i in geometry.ANGLES:
  19. self.assertCountEqual(geometry.triangle(grid_shape, 0, 0, 0, 0, i), [(0,0)])
  20. #TODO: complete
  21. def test_sq_triangle_3d(self):
  22. """test triangle3d algorithms on square grid"""
  23. grid_shape = geometry.SQUARE
  24. #TODO: complete
  25. def test_hex_triangle_3d(self):
  26. """test triangle3d algorithms on hexagonal grid"""
  27. grid_shape = geometry.HEX
  28. #TODO: complete
  29. def test_errors(self):
  30. for grid_shape in (geometry.HEX, geometry.SQUARE):
  31. self.assertRaises(ValueError, geometry.triangle, grid_shape, 0, 0, 0, 0, 0)
  32. self.assertRaises(TypeError, geometry.triangle, grid_shape, "a", 0, 0, 0, 1)
  33. self.assertRaises(TypeError, geometry.triangle, grid_shape, 0, "a", 0, 0, 1)
  34. self.assertRaises(TypeError, geometry.triangle, grid_shape, 0, 0, "a", 0, 1)
  35. self.assertRaises(TypeError, geometry.triangle, grid_shape, 0, 0, 0, "a", 1)
  36. self.assertRaises(ValueError, geometry.triangle, grid_shape, 0, 0, 0, 0, "a")
  37. if __name__ == "__main__":
  38. #import sys;sys.argv = ['', 'Test.test_sq_triangle']
  39. unittest.main()