Example #1
0
 def test_create_fail(self):
     '''Test create with invalid value'''
     if VERSION_INFO >= '2.7':
         for test_value in [1234, [12, 34], {}]:
             with self.assertRaises(ValueError):
                 Hex(test_value)
     else:
         for test_value in [1234, [12, 34], {}]:
             self.assertRaises(ValueError, Hex, test_value)
Example #2
0
 def test_hexes_within_range_cube(self):
     '''Test hexes within range (cubic co-ords)'''
     self.assertTrue(
         hex_grid.hexes_within_range(
             Hex((23, -22, -1)), 1, 'cubic') == [
                 (22, -22, 0),
                 (22, -21, -1),
                 (23, -23, 0),
                 (23, -22, -1),
                 (23, -21, -2),
                 (24, -23, -1),
                 (24, -22, -2)])
Example #3
0
 def test_create_hex(self):
     '''Test create with Hex object'''
     hex1 = Hex('2411')
     try:
         hex2 = Hex(hex1)
         self.assertTrue(hex1.offset() == hex2.offset())
     except ValueError:
         self.fail('Unexpected error')
Example #4
0
 def test_hexes_within_range_offset(self):
     '''Test hexes within range (offset co-ords)'''
     self.assertTrue(
         hex_grid.hexes_within_range(Hex('2311'), 1, 'offset') ==
         ['2210', '2211', '2310', '2311', '2312', '2410', '2411'])
Example #5
0
 def test_cube_to_offset(self):
     '''Test cube to offset co-ordinates'''
     hhex = Hex(self.cube)
     self.assertTrue(hhex.offset() == self.offset)
Example #6
0
 def test_offset_to_cube(self):
     '''Test offset to cube co-ordinates'''
     hhex = Hex(self.offset)
     self.assertTrue(hhex.cube() == self.cube)
Example #7
0
 def test_create_cube(self):
     '''Test create with cube co-ordinates'''
     hhex = Hex((24, -23, -1))
     self.assertTrue(hhex.cube() == (24, -23, -1))
Example #8
0
 def test_create_offset(self):
     '''Test create with offset co-ordinates'''
     hhex = Hex('2411')
     self.assertTrue(hhex.offset() == '2411')