def test_APointAndAnother200MinusXHasDistance200(self): v1 = self.v1[0] (v2x, v2y) = v1 test_point = (v2x - 200, v2y) expected = 200 actual = get_distance(v1, test_point) self.assertEqual(expected, actual)
def parse_input(input_dictionary): v = input_dictionary e = DistanceDictionary() for source_key, source_value in input_dictionary.iteritems(): for target_key, target_value in input_dictionary.iteritems(): if source_key != target_key: e[(source_key, target_key)] = get_distance(source_value, target_value) return v, e
def test_parseInputReturnsEdgesWhichContainTheSourceTargetAndDistance(self): num_test_points = len(self.TEST_POINTS) input_dictionary = {} for i in range(0, num_test_points): input_dictionary[i] = self.TEST_POINTS[i] (actual_v, actual_e) = parse_input(input_dictionary) for i in range(0, num_test_points): for j in range(0, num_test_points): if i != j: expected_key = (i, j) expected_value = get_distance(self.TEST_POINTS[i], self.TEST_POINTS[j]) self.assertEqual(expected_value, actual_e[expected_key])
def test_theDistanceBetween2PointsIsTheRoundedRouteOfTheSumOfSquaresOfTheDifferenceBetweenXAndY(self): for i in range(len(self.expected)): actual = get_distance(self.v1[i], self.v2[i]) self.assertEqual(self.expected[i], actual)
def test_TheSameTwoPointsHaveDistance0Between(self): actual = get_distance(self.v1[0], self.v1[0]) self.assertEqual(0, actual)