From 202e593f8dbc233f575b6da416dc0b032b51b06b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 14 Jul 2009 20:35:48 +0000 Subject: [PATCH] (trunk libT) add tr_truncd() unit test --- libtransmission/utils-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libtransmission/utils-test.c b/libtransmission/utils-test.c index 7dc46427d..eed24edb6 100644 --- a/libtransmission/utils-test.c +++ b/libtransmission/utils-test.c @@ -246,11 +246,18 @@ test_memmem( void ) int main( void ) { + char buf[32]; char *in, *out; int len; int i; int l; + /* tr_truncd */ + tr_snprintf( buf, sizeof( buf ), "%.2f%%", 99.999 ); + check( !strcmp( buf, "100.00%" ) ); + tr_snprintf( buf, sizeof( buf ), "%.2f%%", tr_truncd( 99.999, 2 ) ); + check( !strcmp( buf, "99.99%" ) ); + /* base64 */ out = tr_base64_encode( "YOYO!", -1, &len ); check( out );