2014-01-19 01:09:44 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2013-2014 Mnemosyne LLC
|
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
2014-01-19 01:29:38 +00:00
|
|
|
* $Id$
|
2014-01-19 01:09:44 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
#include <string.h> /* memset () */
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
#include "transmission.h"
|
|
|
|
#include "history.h"
|
|
|
|
|
2012-08-18 16:07:05 +00:00
|
|
|
#include "libtransmission-test.h"
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
static int
|
2012-12-05 17:29:46 +00:00
|
|
|
test1 (void)
|
2010-03-08 04:51:50 +00:00
|
|
|
{
|
2011-02-23 06:01:16 +00:00
|
|
|
tr_recentHistory h;
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
memset (&h, 0, sizeof (tr_recentHistory));
|
2011-04-06 23:27:11 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
tr_historyAdd (&h, 10000, 1);
|
|
|
|
check_int_eq (0, (int)tr_historyGet (&h, 12000, 1000));
|
|
|
|
check_int_eq (1, (int)tr_historyGet (&h, 12000, 3000));
|
|
|
|
check_int_eq (1, (int)tr_historyGet (&h, 12000, 5000));
|
|
|
|
tr_historyAdd (&h, 20000, 1);
|
|
|
|
check_int_eq (0, (int)tr_historyGet (&h, 22000, 1000));
|
|
|
|
check_int_eq (1, (int)tr_historyGet (&h, 22000, 3000));
|
|
|
|
check_int_eq (2, (int)tr_historyGet (&h, 22000, 15000));
|
|
|
|
check_int_eq (2, (int)tr_historyGet (&h, 22000, 20000));
|
2010-03-08 04:51:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
MAIN_SINGLE_TEST (test1)
|