1 #include <ccan/str/base32/base32.h>
2 /* Include the C files directly. */
3 #include <ccan/str/base32/base32.c>
4 #include <ccan/tap/tap.h>
6 static void test(const char *data, const char *b32)
10 ok1(base32_str_size(strlen(data)) == strlen(b32) + 1);
11 ok1(base32_data_size(b32, strlen(b32)) == strlen(data));
12 ok1(base32_encode(data, strlen(data), test, strlen(b32)+1));
13 ok1(strcmp(test, b32) == 0);
14 test[strlen(data)] = '\0';
15 ok1(base32_decode(b32, strlen(b32), test, strlen(data)));
16 ok1(strcmp(test, data) == 0);
21 /* This is how many tests you plan to run */
24 base32_chars = "abcdefghijklmnopqrstuvwxyz234567=";
26 /* Test vectors from RFC, but lower-case */
28 test("f", "my======");
29 test("fo", "mzxq====");
30 test("foo", "mzxw6===");
31 test("foob", "mzxw6yq=");
32 test("fooba", "mzxw6ytb");
33 test("r", "oi======");
34 test("foobar", "mzxw6ytboi======");
36 /* This exits depending on whether all tests passed */