-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now that we no longer use the median filter to keep track of the number of blocks of peers, that's the only place it is used.
- Loading branch information
Showing
5 changed files
with
98 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2011-2014 The Bitcoin Core developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
// | ||
#include "timedata.h" | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
using namespace std; | ||
|
||
BOOST_AUTO_TEST_SUITE(timedata_tests) | ||
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters