Skip to content

Commit

Permalink
Create test for manhattan distance to function
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaFerreira015 committed Sep 12, 2024
1 parent 74c9eb2 commit c3bd44f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/testsgeolinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ def test_invalid_position(self):
with self.assertRaises(ValueError):
self.point.bounding_box(4, 6, position="invalid_position")

def test_manhattan_distance(self):
# Testa a distância de Manhattan entre pontos iguais
result = self.p1.manhattan_distance_to(self.p2)
self.assertEqual(result, 0)

# Testa a distância de Manhattan entre pontos diferentes
result = self.p1.manhattan_distance_to(self.p3)
self.assertEqual(result, abs(1 - 4) + abs(2 - 5) + abs(3 - 6))

# Testa a distância de Manhattan para uma tupla de coordenadas
result = Point((1, 4)).manhattan_distance_to((2, 5))
self.assertEqual(result, abs(1 - 2) + abs(4 - 5))

if __name__ == '__main__':
unittest.main()

0 comments on commit c3bd44f

Please sign in to comment.