1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 18:18:10 +00:00
transmission/libtransmission/utils-test.c
Charles Kerr 7beacb3032 (1) RPC "add-torrent" now lets clients embed base64-encoded metainfo directly into the request
(2) remove the RISON code; it didn't make the final cut
(3) add base64 encode/decode utilities and unit tests
2008-05-20 17:33:54 +00:00

43 lines
861 B
C

#include <stdio.h> /* fprintf */
#include <string.h> /* strcmp */
#include "transmission.h"
#include "utils.h"
#define VERBOSE 0
int test = 0;
#define check(A) { \
++test; \
if (A) { \
if( VERBOSE ) \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
} else { \
if( VERBOSE ) \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
int
main( void )
{
char *in, *out;
int len;
/* base64 */
in = "YOYO!";
out = tr_base64_encode( in, -1, &len );
check( out );
check( !strcmp( out, "WU9ZTyE=\n" ) );
check( len == 9 );
in = tr_base64_decode( out, -1, &len );
check( in );
check( !strcmp( in, "YOYO!" ) );
check( len == 5 );
tr_free( in );
tr_free( out );
return 0;
}