Commit Graph

2 Commits

Author SHA1 Message Date
troytt ad7ced6760 test: 修复三处跳过守卫,它们只在真实资源到位时才暴露
这三个测试都犯了同一个错误:**守卫检查的资源,和实际读取的资源不是同
一个**。在 `samples/d2` 缺席时它们一律静默跳过,看起来是绿的;真实 MPQ
一旦放进来,守卫放行,然后立刻炸在一个完全无关的缺失文件上。

- `tests/dcc.test.ts`
  守卫看 `samples/d2`,扫描目标却硬编码成 `samples/fixtures`——那里没有
  `d2char.mpq`。于是这个套件**从来没有真正跑过**:没资源时跳过,有资源时
  `TypeError: Cannot read properties of null (reading 'listFiles')`。
  目标改为 `samples/d2`;打开归档失败时由"打日志后继续"改为 `throw`
  并带上归档名,避免把"文件缺失"伪装成 100 行之外的空指针;
  `let characters: any` 收紧为 `MpqArchive | null`。

- `tests/widths.test.ts`
  守卫看 `samples/d2`,真实输入却是一个空成员名和
  `scripts/browser/checks/map-widths.txt`——后者在仓库里从未存在过。
  改为按实际输入判断。顺带补 `: string` 标注,否则空字符串字面量会被
  收窄成 `never`。

- `tests/formats-malformed.test.ts`
  守卫看 `samples/d2` 目录是否存在,却去读其中一个散落的 `.cof`。但
  `samples/d2/` 放的是 MPQ **归档**,不是解包后的目录树,目录存在完全
  不能说明那个文件存在。改为直接判断该文件路径。

修复后,在真实 MPQ 就位的情况下:
21 passed | 1 skipped (22 files),421 passed | 2 skipped (423),tsc 0 error。
其中 `dcc.test.ts` 从"0 个测试"变成真正执行。
2026-09-14 14:51:50 +00:00
troytt f52edd85f9 test(formats): 增加针对损坏资产的覆盖率和回归测试 (fixes #11)
Implements regression limits testing bounds limits, invalid header mappings and stream truncations for binary formats, verifying the decoder engine halts cleanly without exception masking or propagation leaks. Ensures zero false positives and safely covers buffer boundary rules.
2026-09-14 13:24:25 +00:00