test: Fix indentation
[libisds.git] / test / offline / b64encode.c
blob390478be7405bc1f96074b729c6d86144d5185aa
1 #include "../test.h"
2 #include "utils.h"
3 #include <string.h>
5 static int test_b64encode(const char *correct, const void *input,
6 size_t length) {
7 char *output = NULL;
9 output = _isds_b64encode(input, length);
11 if (correct == NULL && output == NULL)
12 PASS_TEST;
14 if (correct != NULL && output == NULL)
15 FAIL_TEST("Excpected non-NULL, got NULL");
17 if (correct == NULL && output != NULL) {
18 free(output);
19 FAIL_TEST("Excpected NULL, got non-NULL");
22 if (strcmp(correct, output)) {
23 FAILURE_REASON("Wrong return value: expected=`%s', got=`%s'",
24 correct, output);
25 free(output);
26 return 1;
29 free(output);
30 PASS_TEST;
34 int main(void) {
35 INIT_TEST("b64encode");
37 TEST("generic", test_b64encode, "Af+qVQA=\n", "\x1\xff\xaa\x55", 5);
38 TEST("partial cycle", test_b64encode, "MQA=\n", "1", 2);
39 TEST("1 cycle", test_b64encode, "NDIA\n", "42", 3);
40 TEST("2 cycles", test_b64encode, "MTIzNDUA\n", "12345", 6);
41 TEST("empty string", test_b64encode, "AA==\n", "", 1);
42 TEST("NULL input, 0 length", test_b64encode, "\n", NULL, 0);
43 TEST("non-NULL input, 0 length", test_b64encode, "\n", "", 0);
44 TEST("NULL input, non-zero length", test_b64encode, NULL, NULL, 1);
46 SUM_TEST();