test_triangle.py 1.8 KB

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