Begin unifying baseXX encodings. b64 / hex data strings can now be used with \` as well.

This commit is contained in:
Christoffer Lerno
2024-11-25 16:20:10 +01:00
parent 9112d63655
commit a087ba608b
5 changed files with 56 additions and 52 deletions

View File

@@ -17,24 +17,28 @@ TestCase[] tests = {
{{0xe3, 0xa1}, "E3A1"},
};
fn void! encode() {
fn void! encode()
{
usz n;
char[64] buf;
foreach (t : tests) {
n = hex::encode_bytes(t.dec, buf[..])!;
foreach (t : tests)
{
n = hex::encode_bytes(t.dec, buf[..]);
String want = ((String)t.enc).temp_ascii_to_lower();
assert(want == buf[:n], "encode failed: got: %s, want: %s", buf[:n], want);
@pool()
{
assert(want == hex::encode_temp(t.dec)!);
assert(want == hex::encode_temp(t.dec));
};
}
}
fn void! decode() {
fn void! decode()
{
usz n;
char[64] buf;
foreach (t : tests) {
foreach (t : tests)
{
n = hex::decode_bytes(t.enc, buf[..])!;
assert(t.dec == buf[:n], "decode failed: got: %s, want: %s", buf[:n], t.dec);
@pool()