Beispiel #1
0
 def test_components(self):
     self.assertEqual(Vector(1, 2).components, [1, 2])
Beispiel #2
0
 def test_mul_with_vector(self):
     self.assertEqual(Vector(1, 2) * Vector(2, 3), Vector(2, 6))
Beispiel #3
0
 def test_mul_incompatible_type_error(self):
     with self.assertRaises(TypeError):
         Vector(1, 2) * 'incompatible'
Beispiel #4
0
 def test_sub_with_vector(self):
     self.assertEqual(Vector(3, 5) - Vector(2, 3), Vector(1, 2))
Beispiel #5
0
 def test_mul_with_int(self):
     self.assertEqual(Vector(1, 2) * 2, Vector(2, 4))
Beispiel #6
0
 def test_add_incompatible_vector_error(self):
     with self.assertRaises(TypeError):
         Vector(1, 2) + Vector(1, 2, 3)
Beispiel #7
0
 def test_sub_with_int(self):
     self.assertEqual(Vector(1, 2) - 1, Vector(0, 1))
Beispiel #8
0
 def test_contract(self):
     self.assertEqual(Vector(3, 2).contract(Vector(1, 3)), Vector(1, 2))
Beispiel #9
0
 def test_contract_incompatible_type_error(self):
     with self.assertRaises(TypeError):
         Vector(3, 2).contract('incompatible')
Beispiel #10
0
 def test_expand_incompatible_type_error(self):
     with self.assertRaises(TypeError):
         Vector(1, 2).expand('incompatible')
Beispiel #11
0
 def test_expand_incompatible_vector_error(self):
     with self.assertRaises(TypeError):
         Vector(1, 2).expand(Vector(3, 1, 0))
Beispiel #12
0
 def test_expand(self):
     self.assertEqual(Vector(1, 2).expand(Vector(3, 1)), Vector(3, 2))
Beispiel #13
0
 def test_magnitude(self):
     self.assertEqual(Vector(2, 3, 0.5).magnitude, 3)
Beispiel #14
0
 def test_to_int_list(self):
     self.assertEqual(Vector(1, 2.5).to_int_list(), [1, 2])
Beispiel #15
0
 def test_add_with_float(self):
     self.assertEqual(Vector(1, 2) + 0.5, Vector(1.5, 2.5))
Beispiel #16
0
 def test_contract_incompatible_vector_error(self):
     with self.assertRaises(TypeError):
         Vector(3, 2).contract(Vector(1, 2, 0))
Beispiel #17
0
 def test_add_with_vector(self):
     self.assertEqual(Vector(1, 2) + Vector(2, 3), Vector(3, 5))
Beispiel #18
0
 def test_to_float_list(self):
     self.assertEqual(Vector(1, 2.5).to_float_list(), [1.0, 2.5])
Beispiel #19
0
 def test_repr(self):
     self.assertEqual(repr(Vector(1, 2)), 'Vector(1.0, 2.0)')
Beispiel #20
0
 def test_eq(self):
     self.assertEqual(Vector(1, 2), Vector(1.0, 2.0))
Beispiel #21
0
 def test_sub_with_float(self):
     self.assertEqual(Vector(1, 2) - 0.5, Vector(0.5, 1.5))
Beispiel #22
0
 def test_really_not_eq(self):
     self.assertNotEqual(Vector(1, 2), Vector(2.0, 1.0))
Beispiel #23
0
 def test_sub_incompatible_vector_error(self):
     with self.assertRaises(TypeError):
         Vector(3, 5) - Vector(2, 3, 4)
Beispiel #24
0
 def test_definitely_not_eq(self):
     self.assertNotEqual(Vector(1, 2), Vector(1, 2, 3))
Beispiel #25
0
 def test_mul_with_float(self):
     self.assertEqual(Vector(1, 2) * 0.5, Vector(0.5, 1))
Beispiel #26
0
 def test_really_definitely_not_eq(self):
     self.assertNotEqual(Vector(1, 2), 'incompatible')
Beispiel #27
0
 def test_str(self):
     self.assertEqual(str(Vector(1, 2)), '1 2')
Beispiel #28
0
 def test_add_with_int(self):
     self.assertEqual(Vector(1, 2) + 1, Vector(2, 3))
Beispiel #29
0
 def test_mul_incompatible_vector_error(self):
     with self.assertRaises(TypeError):
         Vector(1, 2) * Vector(2, 3, 4)
Beispiel #30
0
 def test_iter(self):
     self.assertEqual([c for c in Vector(1, 2, 3)], [1, 2, 3])