2010-03-08 04:51:50 +00:00
|
|
|
#include <stdio.h>
|
2011-04-06 23:27:11 +00:00
|
|
|
#include <string.h> /* memset() */
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "history.h"
|
|
|
|
|
|
|
|
#undef VERBOSE
|
2012-08-18 16:07:05 +00:00
|
|
|
#include "libtransmission-test.h"
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
test1( void )
|
|
|
|
{
|
2011-02-23 06:01:16 +00:00
|
|
|
tr_recentHistory h;
|
|
|
|
|
2011-04-06 23:27:11 +00:00
|
|
|
memset( &h, 0, sizeof( tr_recentHistory ) );
|
|
|
|
|
2011-02-23 06:01:16 +00:00
|
|
|
tr_historyAdd( &h, 10000, 1 );
|
2012-08-18 16:07:05 +00:00
|
|
|
check( (int)tr_historyGet( &h, 12000, 1000 ) == 0 );
|
|
|
|
check( (int)tr_historyGet( &h, 12000, 3000 ) == 1 );
|
|
|
|
check( (int)tr_historyGet( &h, 12000, 5000 ) == 1 );
|
2011-02-23 06:01:16 +00:00
|
|
|
tr_historyAdd( &h, 20000, 1 );
|
2012-08-18 16:07:05 +00:00
|
|
|
check( (int)tr_historyGet( &h, 22000, 1000 ) == 0 );
|
|
|
|
check( (int)tr_historyGet( &h, 22000, 3000 ) == 1 );
|
|
|
|
check( (int)tr_historyGet( &h, 22000, 15000 ) == 2 );
|
|
|
|
check( (int)tr_historyGet( &h, 22000, 20000 ) == 2 );
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-18 16:07:05 +00:00
|
|
|
MAIN_SINGLE_TEST(test1)
|