ws-audio: merge master (ws/m4a codecs/Mdct already in use since 6535a3c; audio/opus encoder, data, vec, 3d, webp)
This commit is contained in:
commit
43b8f4b4f5
400 files changed
+82546
-38
No files matched your search
@@ -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()
|
||||
Reference in new issue
Block a user