mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-05-04 20:30:34 +00:00
cleanups, make clang happy
This commit is contained in:
parent
9ac54f6db3
commit
390e8ea9de
11 changed files with 44 additions and 34 deletions
|
@ -10,15 +10,21 @@
|
|||
struct texttestcase {
|
||||
const char *in;
|
||||
const char *out;
|
||||
const char *rev;
|
||||
} tests0[] = {
|
||||
{"", "", ""},
|
||||
{"f", "Zg==", "f"},
|
||||
{"fo", "Zm8=", "fo"},
|
||||
{"foo", "Zm9v", "foo"},
|
||||
{"foob", "Zm9vYg==", "foob"},
|
||||
{"fooba", "Zm9vYmE=", "fooba"},
|
||||
{"foobar", "Zm9vYmFy", "foobar"},
|
||||
{ "" ,"" },
|
||||
{ "f" ,"Zg==" },
|
||||
{ "fo" ,"Zm8=" },
|
||||
{ "foo" ,"Zm9v" },
|
||||
{ "foob" ,"Zm9vYg==" },
|
||||
{ "fooba" ,"Zm9vYmE=" },
|
||||
{ "foobar","Zm9vYmFy" },
|
||||
|
||||
{ "foobarf" ,"Zm9vYmFyZg==" },
|
||||
{ "foobarfo" ,"Zm9vYmFyZm8=" },
|
||||
{ "foobarfoo" ,"Zm9vYmFyZm9v" },
|
||||
{ "foobarfoob" ,"Zm9vYmFyZm9vYg==" },
|
||||
{ "foobarfooba" ,"Zm9vYmFyZm9vYmE=" },
|
||||
{ "foobarfoobar","Zm9vYmFyZm9vYmFy" },
|
||||
};
|
||||
|
||||
int main(void)
|
||||
|
@ -29,19 +35,24 @@ int main(void)
|
|||
base64_to(buf, (const u8 *)tests0[i].in, strlen(tests0[i].in));
|
||||
if (strcmp(buf, tests0[i].out) != 0) {
|
||||
printf("invalid encoding result: \"%s\" -> encoded as \"%s\", but expected \"%s\".\n",
|
||||
tests0[i].in, buf, tests0[i].out);
|
||||
tests0[i].in, buf, tests0[i].out);
|
||||
return 1;
|
||||
}
|
||||
if (strlen(buf) != BASE64_TO_LEN(strlen(tests0[i].in))) {
|
||||
printf("encoded length mismatch: got %d expected %d\n",
|
||||
(int) strlen(buf), (int) BASE64_TO_LEN(strlen(tests0[i].in)));
|
||||
return 1;
|
||||
}
|
||||
if (!base64_valid(buf,0)) {
|
||||
printf("encoded data is considered invalid\n");
|
||||
return 3;
|
||||
return 1;
|
||||
}
|
||||
r = base64_from((u8 *)buf2, buf, strlen(buf));
|
||||
buf2[r] = '\0';
|
||||
if (strcmp(buf2, tests0[i].rev) != 0) {
|
||||
buf2[r] = '\000';
|
||||
if (strcmp(buf2, tests0[i].in) != 0) {
|
||||
printf("invalid decoding result: encoded \"%s\", decoded as \"%s\", but expected \"%s\".\n",
|
||||
tests0[i].out, buf2, tests0[i].rev);
|
||||
return 2;
|
||||
tests0[i].out, buf2, tests0[i].in);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue