tmp/ 가 창끼리 안 건너가는 것이 확정돼(랩탑이 시간 두고 두 번 확인) 시험·예외가 저절로 건너가도록 git 안으로 옮김. 사용자 확정. - 내용은 하나도 안 고침 — 자리만 옮김. tmp/tests 는 남겨 둠. - 같은 이름이 이미 있던 64 개는 랩탑 것을 그대로 두고 건너뜀. - helper_b05_*.js 둘은 랩탑이 .cjs 로 이미 올린 것과 **줄바꿈만 다른 같은 내용**이라 복사본을 도로 뺌(시험이 .cjs 를 부름). - resources/tester/ 에서 전체 1176 통과 · 29 건너뜀 · 실패 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
"""계획노선 사용 범위 절단 (2026-09-04 사용자 지시) 단위 검증."""
|
|
|
|
import math
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.append(str(Path(__file__).resolve().parents[2]))
|
|
|
|
from common_util.common_util_route_geometry import clip_route_by_chainage
|
|
|
|
|
|
def _length(points):
|
|
return sum(math.dist(points[i - 1], points[i]) for i in range(1, len(points)))
|
|
|
|
|
|
LINE = [(0.0, 0.0), (100.0, 0.0), (100.0, 100.0)] # 총 200m
|
|
|
|
|
|
def test_no_range_keeps_all():
|
|
assert clip_route_by_chainage(LINE, None, None) == LINE
|
|
|
|
|
|
def test_start_only():
|
|
out = clip_route_by_chainage(LINE, 50.0, None)
|
|
assert out[0] == (50.0, 0.0)
|
|
assert out[-1] == (100.0, 100.0)
|
|
assert abs(_length(out) - 150.0) < 1e-6
|
|
|
|
|
|
def test_end_only():
|
|
out = clip_route_by_chainage(LINE, None, 150.0)
|
|
assert out[0] == (0.0, 0.0)
|
|
assert abs(out[-1][0] - 100.0) < 1e-6 and abs(out[-1][1] - 50.0) < 1e-6
|
|
assert abs(_length(out) - 150.0) < 1e-6
|
|
|
|
|
|
def test_both_ends_and_interpolated_vertex():
|
|
out = clip_route_by_chainage(LINE, 50.0, 150.0)
|
|
assert abs(_length(out) - 100.0) < 1e-6
|
|
# 꺾임점(100,0)이 구간 안이면 그대로 남는다.
|
|
assert (100.0, 0.0) in [(round(x, 6), round(y, 6)) for x, y in out]
|
|
|
|
|
|
def test_range_outside_data_falls_back_to_full():
|
|
assert clip_route_by_chainage(LINE, 500.0, 900.0) == LINE
|
|
|
|
|
|
def test_reversed_range_falls_back_to_full():
|
|
assert clip_route_by_chainage(LINE, 150.0, 50.0) == LINE
|