vec: vector/tiled (TMX + TMJ + TSX/TSJ read/write into TileMap: all data encodings, chunks, objects, typed properties, tilesets as references); core/Base64 (new, small); Types: TileMap.new + open TileMap/Tileset/TileLayer fields; api: F.save passes the destination extension as opts.format when none is given (tmx vs tmj). Tests vs Tiled exports and Tiled reading our files

This commit is contained in:
4DBug committed 2026-10-31 08:54:35 -05:00
1 parent 63294e13bd
commit a762554f2c
13 files changed
+2239 -3

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
-- core/Base64 tests: the RFC 4648 vectors, whitespace / missing padding / URL-safe input, bad characters, random
-- round trips.
local T = require("@tests/T")
local Base64 = require("@formats/core/Base64")
local t = T.suite("base64")
for _, v in { { "", "" }, { "f", "Zg==" }, { "fo", "Zm8=" }, { "foo", "Zm9v" }, { "foob", "Zm9vYg==" }, { "fooba", "Zm9vYmE=" }, { "foobar", "Zm9vYmFy" } } do
t:eq(Base64.encode(v[1]), v[2], "encode " .. v[1])
t:eq(buffer.tostring(Base64.decode(v[2]) :: buffer), v[1], "decode " .. v[2])
end
t:eq(buffer.tostring(Base64.decode(" Zm9v\nYmE ") :: buffer), "fooba", "whitespace and no padding")
t:eq(buffer.tostring(Base64.decode("-_8=") :: buffer), "\251\255", "URL-safe alphabet")
local b, err = Base64.decode("Zm9v!")
t:check(b == nil and err, "bad character")
local b2 = Base64.decode("Zg==Zg")
t:check(b2 == nil, "data after padding")
local rand = T.rng(5)
for n = 0, 40 do
local s = buffer.create(n)
for i = 0, n - 1 do
buffer.writeu8(s, i, rand(256))
end
t:eq(buffer.tostring(Base64.decode(Base64.encode(s)) :: buffer), buffer.tostring(s), "round trip " .. n)
end
t:done()