1a445343f6
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
37 lines
997 B
C++
37 lines
997 B
C++
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
//
|
|
#include <timedata.h>
|
|
#include <test/test_bitcoin.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(timedata_tests, BasicTestingSetup)
|
|
|
|
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()
|