Files
Aislo/resources/tester/test_est_estplus.py
T
eomsangdonandClaude Opus 5.5 708aeb5cc4 feat(est-test): 구버전 EST Plus(.est) 불러오기·저장·단가비교
- 394/565 바이트 레코드(Extended·ShortString) 읽기·쓰기, 표별 변환과 설계변경 c* 파일
- 호표 코드 매기기·품명규격으로 연결 코드 붙이기, 저장 금액 유지
- 단가비교 창(4종, 차례 짝, 합계 다름 표시, 더블클릭 이동), Ctrl+Alt+E · Ctrl+Shift+F12

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:04:26 +09:00

54 lines
2.0 KiB
Python

"""구버전 EST Plus(.est): 394 바이트 레코드 쓰기→읽기 왕복, 단가비교 자리, 짝짓기."""
import json
import subprocess
from pathlib import Path
from test_est_rea_parity import run
ROOT = Path(__file__).resolve().parents[2]
EST = ROOT / "tools/est-test"
def node(code):
out = subprocess.check_output(
["node", "-e", code], cwd=EST, text=True, encoding="utf-8"
)
return json.loads(out)
def test_extended_and_round_trip_of_sample():
result = node(
"""
const L=require('./legacy-estplus.cjs'),s=require('./sample.json');
const b=Buffer.alloc(10),xs=[0,1,-2.5,1234567.891,0.001,1e15].map(v=>(L.writeX(b,0,v),L.readX(b,0)));
const buf=L.write(s),p=L.read(buf,'t');
const same=(t,keys)=>s.tables[t].every((r,i)=>keys.every(k=>Math.abs((Number(r[k])||0)-(Number(p.tables[t][i][k])||0))<1e-6));
console.log(JSON.stringify({xs,
est:same('EstMainDat',['GN','TU','TC','NC','GC','JC','Level']),
head:same('HeadMainDat',['GN','TC','NC','GC','JC']),
cost:s.tables.CostMainDat.every((r,i)=>r.Index>0||(r.LineData||'')===(p.tables.CostMainDat[i].LineData||'')),
title:p.tables.CostTitleDat[0].Name,labor:p.tables.LaborcDat.length,
linked:p.tables.EstMainDat.find(r=>r.Name==='터파기').Code,auto:p.options.AutoCalc,
cmp:L.compare(buf,2)[0]}));
""")
assert result["xs"] == [0, 1, -2.5, 1234567.891, 0.001, 1e15]
assert result["est"] and result["head"] and result["cost"]
assert result["title"] == "터파기"
assert result["labor"] == 9
assert result["linked"] == "D0000000001"
assert result["auto"] is False
assert result["cmp"] == {"ONU": 66841, "OGU": 1336, "OJU": 0}
def test_pair_flags_sum_mismatch_in_order():
result = run(
"math",
"""(()=>{
const p=EstNative.empty();p.tables.HeadMainDat=[{Index:1,Code:'U1',Name:'a',NC:10,GC:5},{Index:0},
{Index:2,Code:'U2',Name:'b',NC:3}];
return EstEstPlus.pair(p,2,[{ONU:10,OGU:5,OJU:0},{ONU:4,OGU:0,OJU:0}]).map(r=>[r.Code,r.UsesCheck]);
})()""",
)
assert result == [["U1", False], ["U2", True]]