mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Begin unifying baseXX encodings. b64 / hex data strings can now be used with \` as well.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user