# 离线只读验证：不访问网络、不操作设备，只读取同目录合成输入。
import json, math, struct, statistics
from pathlib import Path
def match(f,t):
 p=f.split('/'); q=t.split('/')
 if any(('#' in v and (v!='#' or i!=len(p)-1)) or ('+' in v and v!='+') for i,v in enumerate(p)): return '无效过滤器'
 if t.startswith('$') and p[0] in ('#','+'): return False
 for i,v in enumerate(p):
  if v=='#': return True
  if i>=len(q) or (v!='+' and v!=q[i]): return False
 return len(p)==len(q)
def check(d): return [match(f,t) for f,t in d]

if __name__=='__main__':
 fixture=json.loads(Path(__file__).with_name('fixture.json').read_text(encoding='utf-8'))
 actual=check(fixture['input'])
 assert actual==fixture['expected'], {'实际':actual,'预期':fixture['expected']}
 print(json.dumps({'状态':'通过','实际':actual,'边界':'仅离线合成样例，现场未测'},ensure_ascii=False))
