Example #1
0
 def equilateral_triangle(self):
     formatted_name = classify_triangle(3, 3, 3)
     self.assertEqual(formatted_name, 'equilateral triangle')
Example #2
0
 def isosceles_triangle(self):
     formatted_name = classify_triangle(3, 3, 5)
     self.assertEqual(formatted_name, 'isosceles triangle')
Example #3
0
 def right_triangle(self):
     formatted_name = classify_triangle(3, 4, 5)
     self.assertEqual(formatted_name, 'right triangle')
Example #4
0
def test_right_order():
    """
    Test that a tirangle with a**2 + b**2 = c**2 triangle return 'right' even when c is not the third parameter
    Note: right triangles are also scalene.
    """
    assert 'right' == classify_triangle(5, 3, 4)
Example #5
0
 def scalene_triangle(self):
     formatted_name = classify_triangle(3, 4, 6)
     self.assertEqual(formatted_name, 'scalene triangle')
Example #6
0
def test_right():
    """
    Test that a tirangle with a**2 + b**2 = c**2 triangle returns 'right'
    Note: right triangles are also scalene.
    """
    assert 'right' == classify_triangle(3, 4, 5)
Example #7
0
def test_invalid_zero():
    """
    Test that an null size triangle returns 'invalid'
    """
    assert 'invalid' == classify_triangle(0, 0, 0)
Example #8
0
def test_isosceles():
    """
    Test that a triangle with two equal sides returns 'isosceles'
    """
    assert 'isosceles' == classify_triangle(2, 2, 3)
Example #9
0
def test_scalene():
    """
    Test that a triangle with three differnt sides returns 'scalene'
    """
    assert 'scalene' == classify_triangle(2, 3, 4)
Example #10
0
def test_equilateral():
    """
    Test that a triangle with three equal sides returns 'equilateral'
    Note: equilateral triangles are also isosceles
    """
    assert 'equilateral' == classify_triangle(1.2, 1.2, 1.2)
Example #11
0
def test_invalid_isosceles():
    """
    Test that an invalid triangle with two equal sides returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 1, 3)
Example #12
0
def test_invalid_scalene():
    """
    Test that an invalid triangle with three different lengths returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, 3)
Example #13
0
def test_nan():
    """
    Test that an invalid triangle with a not a number length returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, float('nan'))
Example #14
0
def test_inf():
    """
    Test that an invalid triangle with an infinite length returns 'invalid'
    """
    assert 'invalid' == classify_triangle(1, 2, float('inf'))