2015-12-13 14:51:43 +01:00
|
|
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-08-20 13:53:42 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
//
|
|
|
|
#include "timedata.h"
|
2016-03-03 20:20:32 +01:00
|
|
|
#include "test/test_dash.h"
|
2014-08-20 13:53:42 +02:00
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2015-03-12 09:34:42 +01:00
|
|
|
BOOST_FIXTURE_TEST_SUITE(timedata_tests, BasicTestingSetup)
|
2014-08-20 13:53:42 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(util_MedianFilter)
|
|
|
|
{
|
|
|
|
CMedianFilter<int> filter(5, 15);
|
|
|
|
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 15);
|
|
|
|
|
|
|
|
filter.input(20); // [15 20]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 17);
|
|
|
|
|
|
|
|
filter.input(30); // [15 20 30]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 20);
|
|
|
|
|
|
|
|
filter.input(3); // [3 15 20 30]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 17);
|
|
|
|
|
|
|
|
filter.input(7); // [3 7 15 20 30]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 15);
|
|
|
|
|
|
|
|
filter.input(18); // [3 7 18 20 30]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 18);
|
|
|
|
|
|
|
|
filter.input(0); // [0 3 7 18 30]
|
|
|
|
BOOST_CHECK_EQUAL(filter.median(), 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|