diff options
author | Petr Štetiar <ynezz@true.cz> | 2019-11-19 16:31:44 +0300 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2019-11-24 15:26:58 +0300 |
commit | b0a5cd8a28bf1d1883317ceac6cb8967d840d6ae (patch) | |
tree | 8600f4d551a16671af14f1d086014b111316ea10 /tests/test-b64.c | |
parent | 1fefb7c4d7f90464940143c93e1b98f44ecf6590 (diff) |
add cram based unit tests
For improved QA etc. For the start with initial test cases for avl,
base64, jshn and list components. Moved runqueue and blobmsg from
examples to tests. Converted just a few first test cases from
json-script example into the new cram based unit test, more to come.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'tests/test-b64.c')
-rw-r--r-- | tests/test-b64.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test-b64.c b/tests/test-b64.c new file mode 100644 index 0000000..c29b4e2 --- /dev/null +++ b/tests/test-b64.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <string.h> + +#include "utils.h" + +static void test_b64_encode(const char *src) +{ + char dst[255] = {0}; + int r = b64_encode(src, strlen(src), dst, sizeof(dst)); + fprintf(stdout, "%d %s\n", r, dst); +} + +static void test_b64_decode(const char *src) +{ + char dst[255] = {0}; + int r = b64_decode(src, dst, sizeof(dst)); + fprintf(stdout, "%d %s\n", r, dst); +} + +int main() +{ + test_b64_encode(""); + test_b64_encode("f"); + test_b64_encode("fo"); + test_b64_encode("foo"); + test_b64_encode("foob"); + test_b64_encode("fooba"); + test_b64_encode("foobar"); + + test_b64_decode(""); + test_b64_decode("Zg=="); + test_b64_decode("Zm8="); + test_b64_decode("Zm9v"); + test_b64_decode("Zm9vYg=="); + test_b64_decode("Zm9vYmE="); + test_b64_decode("Zm9vYmFy"); + + return 0; +} |