c29b4e2c73a36a1cc02bc10ccf9c47347e098abc
[project/libubox.git] / tests / test-b64.c
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "utils.h"
5
6 static void test_b64_encode(const char *src)
7 {
8 char dst[255] = {0};
9 int r = b64_encode(src, strlen(src), dst, sizeof(dst));
10 fprintf(stdout, "%d %s\n", r, dst);
11 }
12
13 static void test_b64_decode(const char *src)
14 {
15 char dst[255] = {0};
16 int r = b64_decode(src, dst, sizeof(dst));
17 fprintf(stdout, "%d %s\n", r, dst);
18 }
19
20 int main()
21 {
22 test_b64_encode("");
23 test_b64_encode("f");
24 test_b64_encode("fo");
25 test_b64_encode("foo");
26 test_b64_encode("foob");
27 test_b64_encode("fooba");
28 test_b64_encode("foobar");
29
30 test_b64_decode("");
31 test_b64_decode("Zg==");
32 test_b64_decode("Zm8=");
33 test_b64_decode("Zm9v");
34 test_b64_decode("Zm9vYg==");
35 test_b64_decode("Zm9vYmE=");
36 test_b64_decode("Zm9vYmFy");
37
38 return 0;
39 }