Build Capital Quest for CoCo 3 with maps and emulator tests
This commit is contained in:
commit
9f7d6f4786
44 files changed
+6238
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import json,re
|
||||
from pathlib import Path
|
||||
r=Path(__file__).resolve().parents[1]
|
||||
states=[line.split('\t') for line in (r/'data/states.tsv').read_text().splitlines()]
|
||||
assert len(states)==50 and len({s[0] for s in states})==50
|
||||
assert len({s[1] for s in states})==50 and len({s[2] for s in states})==50
|
||||
assert dict((s[0],s[2]) for s in states)['AK']=='Juneau'
|
||||
assert dict((s[0],s[2]) for s in states)['HI']=='Honolulu'
|
||||
assert all(s[0] not in ('DC','PR') for s in states)
|
||||
m=json.loads((r/'data/map-manifest.json').read_text())
|
||||
s=(r/'src/map_data.c').read_text()
|
||||
for view in ('national','northeast','hawaii'):
|
||||
data=list(map(int,re.search(view+r'_spans\[\] = \{\s*([\d,\s]+)',s)[1].replace('\n','').split(',')))
|
||||
off=list(map(int,re.search(view+r'_offsets\[51\] = \{([\d,]+)',s)[1].split(',')))
|
||||
assert len(off)==51 and off[0]==0 and off[-1]==len(data)
|
||||
w,h=m[view]['size']; occupied=set()
|
||||
for i,state in enumerate(states):
|
||||
area=0
|
||||
for k in range(off[i],off[i+1],3):
|
||||
y,x,n=data[k:k+3];assert 0<=y<h and 0<=x<x+n<=w
|
||||
for xx in range(x,x+n):assert (xx,y) not in occupied;occupied.add((xx,y))
|
||||
area+=n
|
||||
assert area==m[view]['pixels'][state[0]]
|
||||
if view=='national':assert area>0
|
||||
for code in ('CT','DE','ME','MD','MA','NH','NJ','NY','PA','RI','VT'):assert m['northeast']['pixels'][code]>0
|
||||
assert m['hawaii']['pixels']['HI']>400
|
||||
assert all(n==0 for code,n in m['hawaii']['pixels'].items() if code!='HI')
|
||||
print('PASS: 50 unique pairs and geometry IDs, bounded/disjoint spans, all national masks, Northeast and Hawaii detail coverage.')
|
||||
Reference in new issue
Block a user