14 lines
591 B
Python
14 lines
591 B
Python
# Base64 fixtures (tools/fixtures.py): random byte strings of every length 0..70 plus a few large ones, with Python's
|
|
# base64 (standard, URL-safe, unpadded) as the reference.
|
|
# tests/gen/base64_cases.luau { data, std, url, nopad }
|
|
import base64
|
|
|
|
|
|
def generate(ctx):
|
|
rng = ctx.rng(3)
|
|
cases = []
|
|
for n in list(range(71)) + [1000, 4097, 65536]:
|
|
d = bytes(rng.randrange(256) for _ in range(n))
|
|
cases.append({"data": d, "std": base64.b64encode(d), "url": base64.urlsafe_b64encode(d), "nopad": base64.b64encode(d).rstrip(b"=")})
|
|
ctx.emit("base64_cases", cases)
|