Files
Aislo/resources/tester/test_b06_bench_cut_length.py
eomsangdonandClaude Opus 5 0ef32b5279 chore(tester): 시험을 resources/tester/ 로 옮김 — 창끼리 건너가게
⚠ **뿌리** — `tmp/` 는 창 사이에 안 건너감(실측 확인: 상대 창이 놓은 `tmp/_sync_probe.txt`
가 시간을 두고 두 번 봐도 안 보임). 그래서 **정본(등록부 스키마)만 건너가고 그것을 읽는
시험은 안 건너가** 오늘 두 번, 같은 시험이 **연 창은 통과·받은 창은 실패**가 됐음.

- `tmp/tests/*` 를 `resources/tester/` 로 **복사**(127 파일). 내용은 **한 줄도 안 고침**
- `tmp/tests` 는 **남겨 둠** — 되돌릴 자리(사용자 지시)
- 실행: `./venv/Scripts/python.exe -m pytest resources/tester/ -q`
  옮기기 전과 **같은 수**: 617 통과 / 22 건너뜀 / 실패 0

⇒ 이제 시험·예외·까닭이 **정본과 함께** 움직임. 오늘 세운 「예외는 정본 스키마에」와 짝임.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 17:12:30 +09:00

83 lines
2.8 KiB
Python

"""층따기 밑수 — 성토부 아래 원지반의 지표면 길이(m).
근거(2026-09-09 사용자 확정: 단위 ㎡) — 별표2 · 임도기술교본 6장 4절
「경사가 1:4보다 급한 지반 위에 성토를 하는 경우 원지반 표면에 층따기」.
면적은 측점 사이를 이어 B08 이 내고, 여기서는 **측점 하나의 밑수 길이**만 낸다.
"""
from __future__ import annotations
import math
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[2]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from B06_Section.B06_Section_Engine_Areas import ( # noqa: E402
_BENCH_CUT_MIN_GROUND_SLOPE,
_bench_cut_length,
)
def test_완만한_지반은_층따기를_안_한다() -> None:
"""1:4(25%)보다 완만하면 대상이 아니다 — 성토가 있어도 0."""
offsets = [0.0, 1.0, 2.0]
grounds = [0.0, 0.2, 0.4] # 20 % 경사
diffs = [-1.0, -1.0, -1.0] # 전 구간 성토
assert _bench_cut_length(offsets, grounds, diffs) == 0.0
def test_급한_지반의_성토부만_빗변으로_센다() -> None:
offsets = [0.0, 1.0, 2.0]
grounds = [0.0, 0.5, 1.0] # 50 % 경사 — 대상
diffs = [-1.0, -1.0, -1.0]
expected = 2 * math.hypot(1.0, 0.5)
assert _bench_cut_length(offsets, grounds, diffs) == expected
def test_절토부는_안_센다() -> None:
"""층따기는 성토부 아래 원지반에만 한다."""
offsets = [0.0, 1.0]
grounds = [0.0, 0.5]
diffs = [1.0, 1.0] # 절토
assert _bench_cut_length(offsets, grounds, diffs) == 0.0
def test_절성토_경계는_영교점까지만_센다() -> None:
offsets = [0.0, 1.0]
grounds = [0.0, 0.5]
diffs = [1.0, -1.0] # 가운데에서 절토→성토
expected = math.hypot(1.0, 0.5) * 0.5
assert math.isclose(_bench_cut_length(offsets, grounds, diffs), expected, rel_tol=1e-12)
def test_내리막도_오르막과_같이_센다() -> None:
"""기울기의 방향이 아니라 급한지만 본다."""
up = _bench_cut_length([0.0, 1.0], [0.0, 0.5], [-1.0, -1.0])
down = _bench_cut_length([0.0, 1.0], [0.5, 0.0], [-1.0, -1.0])
assert math.isclose(up, down, rel_tol=1e-12)
def test_문턱값이_법정_1대4_이다() -> None:
assert _BENCH_CUT_MIN_GROUND_SLOPE == 0.25
def test_설계_결과에_밑수가_실린다() -> None:
"""엔진 결과 dict 에 키가 있어야 B08 이 읽는다."""
from B06_Section.B06_Section_Engine_Design import compute_cross_design
ground = [
{"offset_m": offset / 2.0, "elevation_m": 100.0 - (offset / 2.0) * 0.5}
for offset in range(-24, 25)
]
result = compute_cross_design(
ground,
100.0,
ground_type="soil",
section_mode="left_cut",
)
assert "bench_cut_length_m" in result
assert result["bench_cut_length_m"] >= 0.0