2014-03-18 20:46:15 +01:00
|
|
|
import unittest
|
|
|
|
|
|
2014-06-11 15:06:22 +02:00
|
|
|
from difference_of_squares import difference, square_of_sum, sum_of_squares
|
|
|
|
|
|
2014-03-18 20:46:15 +01:00
|
|
|
|
2017-10-14 12:31:08 +01:00
|
|
|
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
|
2014-03-18 20:46:15 +01:00
|
|
|
|
2017-03-21 17:02:00 +01:00
|
|
|
class DifferenceOfSquaresTest(unittest.TestCase):
|
2017-05-17 17:39:54 +02:00
|
|
|
def test_square_of_sum_1(self):
|
|
|
|
|
self.assertEqual(square_of_sum(1), 1)
|
|
|
|
|
|
2014-03-18 20:46:15 +01:00
|
|
|
def test_square_of_sum_5(self):
|
2017-03-21 17:02:00 +01:00
|
|
|
self.assertEqual(square_of_sum(5), 225)
|
2014-03-18 20:46:15 +01:00
|
|
|
|
|
|
|
|
def test_square_of_sum_100(self):
|
2017-03-21 17:02:00 +01:00
|
|
|
self.assertEqual(square_of_sum(100), 25502500)
|
|
|
|
|
|
2017-05-17 17:39:54 +02:00
|
|
|
def test_sum_of_squares_1(self):
|
|
|
|
|
self.assertEqual(sum_of_squares(1), 1)
|
|
|
|
|
|
2017-03-21 17:02:00 +01:00
|
|
|
def test_sum_of_squares_5(self):
|
|
|
|
|
self.assertEqual(sum_of_squares(5), 55)
|
|
|
|
|
|
2014-03-18 20:46:15 +01:00
|
|
|
def test_sum_of_squares_100(self):
|
2017-03-21 17:02:00 +01:00
|
|
|
self.assertEqual(sum_of_squares(100), 338350)
|
|
|
|
|
|
2017-05-17 17:39:54 +02:00
|
|
|
def test_difference_of_squares_1(self):
|
|
|
|
|
self.assertEqual(difference(1), 0)
|
2017-03-21 17:02:00 +01:00
|
|
|
|
|
|
|
|
def test_difference_of_squares_5(self):
|
|
|
|
|
self.assertEqual(difference(5), 170)
|
|
|
|
|
|
|
|
|
|
def test_difference_of_squares_100(self):
|
|
|
|
|
self.assertEqual(difference(100), 25164150)
|
2014-03-18 20:46:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|