• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/libubox/tests/test-b64.c

  1 #include <stdio.h>
  2 #include <string.h>
  3 #include <stdlib.h>
  4 
  5 #include "utils.h"
  6 
  7 #define BUF_LEN 255
  8 
  9 static void test_b64_encode(const char *src)
 10 {
 11         char *dst = malloc(BUF_LEN+1);
 12         int r = b64_encode(src, strlen(src), dst, BUF_LEN);
 13         fprintf(stdout, "%d %s\n", r, dst);
 14         free(dst);
 15 }
 16 
 17 static void test_b64_decode(const char *src)
 18 {
 19         char *dst = malloc(BUF_LEN+1);
 20         int r = b64_decode(src, dst, BUF_LEN);
 21         fprintf(stdout, "%d %s\n", r, dst);
 22         free(dst);
 23 }
 24 
 25 int main()
 26 {
 27         test_b64_encode("");
 28         test_b64_encode("f");
 29         test_b64_encode("fo");
 30         test_b64_encode("foo");
 31         test_b64_encode("foob");
 32         test_b64_encode("fooba");
 33         test_b64_encode("foobar");
 34 
 35         test_b64_decode("");
 36         test_b64_decode("Zg==");
 37         test_b64_decode("Zm8=");
 38         test_b64_decode("Zm9v");
 39         test_b64_decode("Zm9vYg==");
 40         test_b64_decode("Zm9vYmE=");
 41         test_b64_decode("Zm9vYmFy");
 42 
 43         return 0;
 44 }
 45 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt