def test_perimeter_two_vectors(self): u = (1, 2) v = (3, 4) with self.assertRaises( TypeError, msg='should raise TypeError when passing only one vector'): perimeter([u, v])
def test_perimeter_vectors_holding_other_than_numbers(self): u = ('a', 'b') v = ('c', 'd') w = ('e', 'f') with self.assertRaises( TypeError, msg= 'should raise TypeError when passing vectors holding no numeric values' ): perimeter([u, v, w])
def test_perimeter_vectors_different_sizes(self): u = (0, 0) v = (1, 0) w = (0, 1, 0) with self.assertRaises( ValueError, msg= 'should raise ValueError when passing two vectors of different sizes' ): perimeter([u, v, w])
def test_3d_perimeter_happy_path(self): v1 = (0, 0, 1) v2 = (1, 0, 1) v3 = (0, 1, 1) perimeter_actual_result = perimeter([v1, v2, v3]) perimeter_expected_result = 1 + sqrt(2) + 1 self.assertEqual(perimeter_actual_result, perimeter_expected_result, 'add 2 vectors of same size should match')
def test_perimeter_single_vector(self): u = (1, 2) with self.assertRaises( TypeError, msg='should raise TypeError when passing only one vector'): perimeter(u)