diff options
| -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") |
