diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-21 22:40:43 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-21 22:40:43 +0800 |
| commit | 7c45d027a833a5038660952873424465b25e1e55 (patch) | |
| tree | 463f11ae17d348c248047e012294625b3569bf10 /src | |
| parent | dff19d9ab83fabc0b0d6319d2f8f93c088951438 (diff) | |
| download | living-village-7c45d027a833a5038660952873424465b25e1e55.tar.gz | |
test(desktop): CJK 清单唯一性与图集网格防复发断言
- 断言 cjk-glyphs.txt 非空、每行恰 1 字符、字符唯一
- 读 cjk-glyph-atlas.png IHDR,断言 16 列且网格容量覆盖清单、无多余空行
Diffstat (limited to 'src')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index d5602e8..eeafb56 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -1018,3 +1018,36 @@ type PrototypeTests () = |> List.filter (fun relativePath -> not (File.Exists(Path.Combine(AppContext.BaseDirectory, relativePath)))) Assert.AreEqual<string list>([], missing, sprintf "Missing Jiangnan PNG assets: %s" (String.concat ", " missing)) + + [<TestMethod>] + member _.CjkGlyphManifestIsUniqueAndMatchesAtlasGrid () = + // 防复发:图集用字增长时,清单必须非空、每行恰 1 个字符、字符唯一, + // 且与 16 列图集网格自洽(打包脚本不再硬编码行数)。 + let assets = Path.Combine(AppContext.BaseDirectory, "Assets") + let manifestPath = Path.Combine(assets, "cjk-glyphs.txt") + let atlasPath = Path.Combine(assets, "cjk-glyph-atlas.png") + Assert.IsTrue(File.Exists manifestPath, "missing cjk-glyphs.txt") + Assert.IsTrue(File.Exists atlasPath, "missing cjk-glyph-atlas.png") + + let lines = File.ReadAllLines manifestPath + Assert.IsTrue(lines.Length > 0, "CJK manifest must not be empty") + for index in 0 .. lines.Length - 1 do + Assert.AreEqual<int>(1, lines.[index].Length) + Assert.AreEqual<int>(lines.Length, (Set.ofArray lines).Count) + + let header = File.ReadAllBytes atlasPath + let be32 offset = + (int header.[offset] <<< 24) + ||| (int header.[offset + 1] <<< 16) + ||| (int header.[offset + 2] <<< 8) + ||| int header.[offset + 3] + let cell = 24 + let width = be32 16 + let height = be32 20 + Assert.AreEqual<int>(0, width % cell) + Assert.AreEqual<int>(0, height % cell) + let columns = width / cell + let capacity = columns * (height / cell) + Assert.AreEqual<int>(16, columns) + Assert.IsTrue(capacity >= lines.Length, "CJK atlas grid must cover every manifest character") + Assert.IsTrue(capacity - lines.Length < columns, "CJK atlas must not keep an extra empty row") |
