Test that point order doesn't affect the result.
()
| 244 | |
| 245 | |
| 246 | def test_random_order() -> None: |
| 247 | """Test that point order doesn't affect the result.""" |
| 248 | p1 = Point(0, 0) |
| 249 | p2 = Point(4, 0) |
| 250 | p3 = Point(4, 3) |
| 251 | p4 = Point(0, 3) |
| 252 | p5 = Point(2, 1.5) # Interior |
| 253 | |
| 254 | # Try different orderings |
| 255 | order1 = [p1, p2, p3, p4, p5] |
| 256 | order2 = [p5, p4, p3, p2, p1] |
| 257 | order3 = [p3, p5, p1, p4, p2] |
| 258 | |
| 259 | hull1 = graham_scan(order1) |
| 260 | hull2 = graham_scan(order2) |
| 261 | hull3 = graham_scan(order3) |
| 262 | |
| 263 | # All should have the same points (though possibly in different order) |
| 264 | assert len(hull1) == len(hull2) == len(hull3) == 4 |
| 265 | assert {(p.x, p.y) for p in hull1} == {(p.x, p.y) for p in hull2} |
| 266 | assert {(p.x, p.y) for p in hull2} == {(p.x, p.y) for p in hull3} |
nothing calls this directly
no test coverage detected