Translation update done using Pootle.
[gammu.git] / tests / base64.c
blob11b75d704dc1c39952ac9107ade019218ebec5f4
1 /**
2 * Test case for base 64 encoder/decoder in Gammu
3 */
5 #include <gammu.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
10 #include "common.h"
12 #include "../libgammu/misc/coding/coding.h"
15 static const char base64[] =
16 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz"
17 "IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg"
18 "dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu"
19 "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo"
20 "ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
22 static const char text[] = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.";
25 int main(int argc UNUSED, char **argv UNUSED)
27 char *decoded;
28 char *encoded;
29 size_t len;
31 decoded = malloc(sizeof(base64));
32 encoded = malloc(sizeof(base64));
35 len = DecodeBASE64(base64, decoded, strlen(base64));
36 decoded[len] = 0;
38 test_result(len == strlen(text));
39 test_result(strcmp(decoded, text) == 0);
41 EncodeBASE64(text, encoded, strlen(text));
43 test_result(strcmp(base64, encoded) == 0);
45 free(encoded);
46 free(decoded);
48 return 0;
51 /* Editor configuration
52 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: