* Corrected small typos around resistor bands. * Due to failing CI, alterations to the test generator script were needed. The generated vs submitted diff now skips the first three lines of the file so that the generation date is not picked up and flagged as needing regeneration. Sadly, a workaround was also needed to prevent Python difflib from noting the difference anyways and producing an empty "false positive" diff. All templates and test files also needed to be altered to ensure that the first three lines of every test file will always be the autogeneration comment and date. Hopefully, this will now stop the CI failures without creating any subtle additional bugs. * Touch up to bowling template. Added back the error raising utility. * Touch up to two-bucket template to add back in error raising utility. [no important files changed]
81 lines
2.5 KiB
Python
81 lines
2.5 KiB
Python
# These tests are auto-generated with test data from:
|
|
# https://github.com/exercism/problem-specifications/tree/main/exercises/triangle/canonical-data.json
|
|
# File last updated on 2023-07-19
|
|
|
|
import unittest
|
|
|
|
from triangle import (
|
|
equilateral,
|
|
isosceles,
|
|
scalene,
|
|
)
|
|
|
|
|
|
class EquilateralTriangleTest(unittest.TestCase):
|
|
def test_all_sides_are_equal(self):
|
|
self.assertIs(equilateral([2, 2, 2]), True)
|
|
|
|
def test_any_side_is_unequal(self):
|
|
self.assertIs(equilateral([2, 3, 2]), False)
|
|
|
|
def test_no_sides_are_equal(self):
|
|
self.assertIs(equilateral([5, 4, 6]), False)
|
|
|
|
def test_all_zero_sides_is_not_a_triangle(self):
|
|
self.assertIs(equilateral([0, 0, 0]), False)
|
|
|
|
def test_sides_may_be_floats(self):
|
|
self.assertIs(equilateral([0.5, 0.5, 0.5]), True)
|
|
|
|
|
|
class IsoscelesTriangleTest(unittest.TestCase):
|
|
def test_last_two_sides_are_equal(self):
|
|
self.assertIs(isosceles([3, 4, 4]), True)
|
|
|
|
def test_first_two_sides_are_equal(self):
|
|
self.assertIs(isosceles([4, 4, 3]), True)
|
|
|
|
def test_first_and_last_sides_are_equal(self):
|
|
self.assertIs(isosceles([4, 3, 4]), True)
|
|
|
|
def test_equilateral_triangles_are_also_isosceles(self):
|
|
self.assertIs(isosceles([4, 4, 4]), True)
|
|
|
|
def test_no_sides_are_equal(self):
|
|
self.assertIs(isosceles([2, 3, 4]), False)
|
|
|
|
def test_first_triangle_inequality_violation(self):
|
|
self.assertIs(isosceles([1, 1, 3]), False)
|
|
|
|
def test_second_triangle_inequality_violation(self):
|
|
self.assertIs(isosceles([1, 3, 1]), False)
|
|
|
|
def test_third_triangle_inequality_violation(self):
|
|
self.assertIs(isosceles([3, 1, 1]), False)
|
|
|
|
def test_sides_may_be_floats(self):
|
|
self.assertIs(isosceles([0.5, 0.4, 0.5]), True)
|
|
|
|
|
|
class ScaleneTriangleTest(unittest.TestCase):
|
|
def test_no_sides_are_equal(self):
|
|
self.assertIs(scalene([5, 4, 6]), True)
|
|
|
|
def test_all_sides_are_equal(self):
|
|
self.assertIs(scalene([4, 4, 4]), False)
|
|
|
|
def test_first_and_second_sides_are_equal(self):
|
|
self.assertIs(scalene([4, 4, 3]), False)
|
|
|
|
def test_first_and_third_sides_are_equal(self):
|
|
self.assertIs(scalene([3, 4, 3]), False)
|
|
|
|
def test_second_and_third_sides_are_equal(self):
|
|
self.assertIs(scalene([4, 3, 3]), False)
|
|
|
|
def test_may_not_violate_triangle_inequality(self):
|
|
self.assertIs(scalene([7, 3, 2]), False)
|
|
|
|
def test_sides_may_be_floats(self):
|
|
self.assertIs(scalene([0.5, 0.4, 0.6]), True)
|