-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
from rox_vectors import Vector | ||
from roxbot.pathgen.generators import generate_square_path | ||
|
||
|
||
def test_generate_square_path() -> None: | ||
# Test case 1: Simple square | ||
a = Vector(0, 0) | ||
b = Vector(3, 0) | ||
c = Vector(0, 3) | ||
|
||
waypoints = generate_square_path(a, b, c) | ||
|
||
assert len(waypoints) == 4, "Should return 4 waypoints" | ||
assert waypoints[0] == a, "First waypoint should be A" | ||
assert waypoints[1] == b, "Second waypoint should be B" | ||
assert waypoints[3] == c, "Last waypoint should be C" | ||
|
||
# Check if X forms a square | ||
ab = waypoints[1] - waypoints[0] | ||
bx = waypoints[2] - waypoints[1] | ||
xc = waypoints[3] - waypoints[2] | ||
ca = waypoints[0] - waypoints[3] | ||
|
||
assert abs(ab) == pytest.approx(abs(bx)), "AB and BX should have equal length" | ||
assert abs(bx) == pytest.approx(abs(xc)), "BX and XC should have equal length" | ||
assert abs(xc) == pytest.approx(abs(ca)), "XC and CA should have equal length" | ||
assert abs(ab.dot(bx)) < 1e-10, "AB and BX should be perpendicular" |