"""관 벽 최소 높이 거울 — 파이썬(`B06_Section_Engine_Culvert`) ↔ TS(`_Cross_Culvert_Const.ts`). ⚠ 횡단도(TS)가 그리는 높이와 구조물 표·구조물도 그림(파이썬)이 같은 벽을 다르게 그리면 결함 (2026-09-14 브레인 판정). 상수 셋이 같고 식이 같으면 같은 값. """ from __future__ import annotations import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from B06_Section import B06_Section_Engine_Culvert as culvert # noqa: E402 TS = (ROOT / "B06_Section" / "B06_Section_UI_Cross_Culvert_Const.ts").read_text(encoding="utf-8") #: 세트 스펙 TS 짝(`common_util_culvert_sets.ts`)도 같은 상수를 들고 있음 — 셋을 함께 대조. SETS = (ROOT / "common_util" / "common_util_culvert_sets.ts").read_text(encoding="utf-8") def _ts_const(source: str, name: str) -> float: return float(re.search(rf"export const {name} = ([\d.]+);", source).group(1)) def test_상수_셋이_TS_와_같다() -> None: for name in ("REVET_FREEBOARD_M", "REVET_HEIGHT_STEP_M", "REVET_EMBED_DEPTH_M"): assert getattr(culvert, name) == _ts_const(TS, name) == _ts_const(SETS, name), name def test_TS_식_모양이_그대로다() -> None: """식을 바꾸면 여기서 잡힘 — 파이썬 식도 함께 고칠 것.""" assert "const raw = diameterM + REVET_FREEBOARD_M;" in TS assert "Math.ceil(raw / REVET_HEIGHT_STEP_M - 1e-9) * REVET_HEIGHT_STEP_M" in TS assert "return revetTargetHeight(diameterM) + REVET_EMBED_DEPTH_M;" in TS def test_관경별_최소_높이() -> None: assert culvert.pipe_wall_min_height_m(1.0) == 2.0 assert culvert.pipe_wall_min_height_m(0.8) == 1.8 assert culvert.pipe_wall_min_height_m(1.2) == 2.2