예제 #1
0
 def test_truncate(self):
     test_vector = ppb_vector.Vector2(700, 500)
     test_vector_truncated = test_vector.truncate(5)
     print(test_vector_truncated)
     self.assertEqual(
         test_vector_truncated,
         ppb_vector.Vector2(4.068667356033675, 2.906190968595482)
     )
예제 #2
0
 def test_is_iterable(self):
     test_vector = ppb_vector.Vector2(3, 4)
     test_tuple = tuple(test_vector)
     print(test_tuple)
     self.assertEqual(test_tuple[0], 3)
     self.assertEqual(test_tuple[1], 4)
예제 #3
0
def test_equal():
    test_vector_1 = ppb_vector.Vector2(50, 800)
    test_vector_2 = ppb_vector.Vector2(50, 800)

    assert test_vector_1 == test_vector_2
def test_normalize(x, y, expected):
    vector = ppb_vector.Vector2(x, y).normalize()
    assert vector.length == expected
예제 #5
0
def test_length(x, y, expected):
    vector = ppb_vector.Vector2(x, y)
    assert vector.length == expected