From 1dafe0beef3f7cf9e3bb23b14f2352a0fd47d57b Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 14 Oct 2012 23:38:52 +0000 Subject: [PATCH] more unit test cleanup --- libtransmission/bencode-test.c | 9 ++++----- libtransmission/clients-test.c | 4 +--- libtransmission/history-test.c | 1 - libtransmission/json-test.c | 3 +-- libtransmission/libtransmission-test.h | 2 -- libtransmission/magnet-test.c | 19 +------------------ libtransmission/metainfo-test.c | 1 - libtransmission/rpc-test.c | 2 -- libtransmission/utils-test.c | 6 ++---- 9 files changed, 9 insertions(+), 38 deletions(-) diff --git a/libtransmission/bencode-test.c b/libtransmission/bencode-test.c index b5639722c..5a5c1a66e 100644 --- a/libtransmission/bencode-test.c +++ b/libtransmission/bencode-test.c @@ -1,7 +1,6 @@ -#include -#include -#include -#include +#include /* isspace() */ +#include /* EILSEQ */ +#include /* strlen(), strncmp() */ #include @@ -491,7 +490,7 @@ testParse2( void ) tr_bencDictAddStr( &top, "this-is-a-string", "this-is-a-string" ); benc = tr_bencToStr( &top, TR_FMT_BENC, &len ); - check( !strcmp( benc, "d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-inti1234ee" ) ); + check_streq( "d14:this-is-a-booli1e14:this-is-a-real8:0.50000016:this-is-a-string16:this-is-a-string14:this-is-an-inti1234ee", benc ); check( !tr_bencParse( benc, benc+len, &top2, &end ) ); check( (char*)end == benc + len ); check( tr_bencIsDict( &top2 ) ); diff --git a/libtransmission/clients-test.c b/libtransmission/clients-test.c index d58293127..3b7248e45 100644 --- a/libtransmission/clients-test.c +++ b/libtransmission/clients-test.c @@ -1,5 +1,3 @@ -#include -#include #include "transmission.h" #include "clients.h" @@ -9,7 +7,7 @@ #define TEST_CLIENT( A, B ) \ tr_clientForId( buf, sizeof( buf ), A ); \ - check( !strcmp( buf, B ) ); + check_streq( B, buf ); int main( void ) diff --git a/libtransmission/history-test.c b/libtransmission/history-test.c index 370a736c0..b4cd59f47 100644 --- a/libtransmission/history-test.c +++ b/libtransmission/history-test.c @@ -1,4 +1,3 @@ -#include #include /* memset() */ #include "transmission.h" diff --git a/libtransmission/json-test.c b/libtransmission/json-test.c index b3a0c4f31..43656092b 100644 --- a/libtransmission/json-test.c +++ b/libtransmission/json-test.c @@ -1,5 +1,4 @@ -#include -#include +#include /* strlen() */ #include "transmission.h" #include "bencode.h" #include "json.h" diff --git a/libtransmission/libtransmission-test.h b/libtransmission/libtransmission-test.h index 9661952ed..32f0ec03d 100644 --- a/libtransmission/libtransmission-test.h +++ b/libtransmission/libtransmission-test.h @@ -4,9 +4,7 @@ #define LIBTRANSMISSION_TEST_H 1 #include -#include -#include "transmission.h" #include "utils.h" /* tr_strcmp0() */ static int current_test = 0; diff --git a/libtransmission/magnet-test.c b/libtransmission/magnet-test.c index 90236a08f..4b0e7e912 100644 --- a/libtransmission/magnet-test.c +++ b/libtransmission/magnet-test.c @@ -1,10 +1,7 @@ -#include -#include #include "transmission.h" #include "magnet.h" #include "utils.h" -/* #define VERBOSE */ #undef VERBOSE #include "libtransmission-test.h" @@ -59,19 +56,5 @@ test1( void ) return 0; } -int -main( void ) -{ - const testFunc tests[] = { test1 }; - int ret; - - if( (ret = runTests(tests, 1)) ) - return ret; - -#ifdef VERBOSE - fprintf( stderr, "magnet-test passed\n" ); -#endif - - return 0; -} +MAIN_SINGLE_TEST(test1) diff --git a/libtransmission/metainfo-test.c b/libtransmission/metainfo-test.c index 51da5b179..d02c60c81 100644 --- a/libtransmission/metainfo-test.c +++ b/libtransmission/metainfo-test.c @@ -1,5 +1,4 @@ #include "transmission.h" -#include "utils.h" /* tr_strcmp0 */ #undef VERBOSE #include "libtransmission-test.h" diff --git a/libtransmission/rpc-test.c b/libtransmission/rpc-test.c index 38e8ef3d7..27fc96ff7 100644 --- a/libtransmission/rpc-test.c +++ b/libtransmission/rpc-test.c @@ -1,5 +1,3 @@ -#include /* fprintf */ -#include /* strcmp */ #include "transmission.h" #include "bencode.h" #include "rpcimpl.h" diff --git a/libtransmission/utils-test.c b/libtransmission/utils-test.c index 2944b524c..12ec74987 100644 --- a/libtransmission/utils-test.c +++ b/libtransmission/utils-test.c @@ -1,6 +1,5 @@ -#include -#include /* fprintf */ -#include /* strcmp */ +#include /* sqrt() */ +#include /* strlen() */ #include "transmission.h" #include "bitfield.h" @@ -426,7 +425,6 @@ test_truncd( void ) tr_snprintf( buf, sizeof( buf ), "%.2f%%", 99.999 ); check_streq("100.00%", buf); - check( !strcmp( buf, "100.00%" ) ); tr_snprintf( buf, sizeof( buf ), "%.2f%%", tr_truncd( 99.999, 2 ) ); check_streq("99.99%", buf);