def test_distance( self ): rows, cols = ( 8, 8 ) tests = [ ( ( 0, 0 ), ( 1, 0 ), 1 ), ( ( 0, 0 ), ( 1, 1 ), 1 ), ( ( 0, 0 ), ( 1, 2 ), 2 ), ( ( 5, 3 ), ( 9, 5 ), 4 ), ( ( 9, 5 ), ( 5, 3 ), 4 ), ( ( 7, 4 ), ( 3, 2 ), 4 ), ] m = Map( ( rows, cols ) ) for start, end, distance in tests: d = m.distance( start, end ) self.assertTrue( distance == d, "Distance between %s, %s, expected to be %s, got %s" % ( start, end, distance, d ) )
def test_distance(self): rows, cols = (8, 8) tests = [ ((0, 0), (1, 0), 1), ((0, 0), (1, 1), 1), ((0, 0), (1, 2), 2), ((5, 3), (9, 5), 4), ((9, 5), (5, 3), 4), ((7, 4), (3, 2), 4), ] m = Map((rows, cols)) for start, end, distance in tests: d = m.distance(start, end) self.assertTrue( distance == d, "Distance between %s, %s, expected to be %s, got %s" % (start, end, distance, d) )