def test_parsing_tuples(self): with open(self.input, 'r') as f: points = f.read().splitlines() first_point = points[1] second_point = points[2] third_point = points[3] self.assertEqual(solution.point(first_point), (6.422011725438139, 5.833206713226367)) self.assertEqual(solution.point(second_point), (3.154480546252892, 4.063265532639129)) self.assertEqual(solution.point(third_point), (8.894562467908552, 0.3522346393034437))
def test_solve_small(self): data = [point(x, x * x * x) for x in range(0, 11)] self.assertEqual(74L, solve(data, 3))
def test_solve(self): data = [point(x, x * x * x) for x in range(0, 100)] self.assertEqual(74, solve(data, 3))
def test_get_fit(self): data = [point(x, x * x * x) for x in range(0, 11)] expected = [1, 15, 58] for i in range(1, 4): self.assertEqual(expected[i - 1], getFirstIncorrectTerm(data, i))
def test_interpolate_not_equals_for_points_equal_and_greater_than_polynomial_order(self): data = [point(x, long(x * x * x)) for x in range(0, 10)] for k in range(4, 6): self.assertNotEqual(data[k].y, interpolate(data, k, 3))
def test_interpolate_equals_for_points_less_than_polynomial_order(self): data = [point(x, x * x * x) for x in range(0, 10)] for k in range(1, 3): self.assertEqual(data[k].y, interpolate(data, k, 3))