コード例 #1
0
 def test_rotate2d_multiple_vector_arg_dimension(self):
     angle = pi
     v = (1, 0, 0)
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing 2D vector'):
         rotate2d_multiple(angle, [v])
コード例 #2
0
 def test_rotate2d_multiple_rotation_arg(self):
     angle = 'a'
     v = (1, 0)
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing numeric angle'):
         rotate2d_multiple(angle, [v])
コード例 #3
0
 def test_rotate2d_multiple_vector_arg_numeric(self):
     angle = pi
     v = ('a', 'b')
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing numeric 2D vector'
     ):
         rotate2d_multiple(angle, [v])
コード例 #4
0
 def test_rotate2d_multiple_happy_path(self):
     angle = pi / 2
     vectors = [(1, 0), (2, 2)]
     actual_rotate2d_multiple_result = rotate2d_multiple(angle, vectors)
     expected_rotate2d_multiple_result = [(0, 1), (-2, 2)]
     self.assertAlmostEqual(
         actual_rotate2d_multiple_result[0][0],
         expected_rotate2d_multiple_result[0][0],
         msg='rotate2d x should approximately match for v[0]')
     self.assertAlmostEqual(
         actual_rotate2d_multiple_result[0][1],
         expected_rotate2d_multiple_result[0][1],
         msg='rotate2d y should approximately match for v[0]')
     self.assertAlmostEqual(
         actual_rotate2d_multiple_result[1][0],
         expected_rotate2d_multiple_result[1][0],
         msg='rotate2d x should approximately match for v[1]')
     self.assertAlmostEqual(
         actual_rotate2d_multiple_result[1][1],
         expected_rotate2d_multiple_result[1][1],
         msg='rotate2d x should approximately match for v[1]')
コード例 #5
0
 def test_rotate2d_multiple_no_vectors(self):
     angle = pi
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not passing numeric angle'):
         rotate2d_multiple(angle, [])