LCOV - code coverage report
Current view: top level - src/test - timedata_tests.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 18 18 100.0 %
Date: 2015-10-12 22:39:14 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2014 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : //
       5             : #include "timedata.h"
       6             : #include "test/test_bitcoin.h"
       7             : 
       8             : #include <boost/test/unit_test.hpp>
       9             : 
      10             : using namespace std;
      11             : 
      12           1 : BOOST_FIXTURE_TEST_SUITE(timedata_tests, BasicTestingSetup)
      13             : 
      14           6 : BOOST_AUTO_TEST_CASE(util_MedianFilter)
      15             : {
      16           1 :     CMedianFilter<int> filter(5, 15);
      17             : 
      18           5 :     BOOST_CHECK_EQUAL(filter.median(), 15);
      19             : 
      20           1 :     filter.input(20); // [15 20]
      21           5 :     BOOST_CHECK_EQUAL(filter.median(), 17);
      22             : 
      23           1 :     filter.input(30); // [15 20 30]
      24           5 :     BOOST_CHECK_EQUAL(filter.median(), 20);
      25             : 
      26           1 :     filter.input(3); // [3 15 20 30]
      27           5 :     BOOST_CHECK_EQUAL(filter.median(), 17);
      28             : 
      29           1 :     filter.input(7); // [3 7 15 20 30]
      30           5 :     BOOST_CHECK_EQUAL(filter.median(), 15);
      31             : 
      32           1 :     filter.input(18); // [3 7 18 20 30]
      33           5 :     BOOST_CHECK_EQUAL(filter.median(), 18);
      34             : 
      35           1 :     filter.input(0); // [0 3 7 18 30]
      36           5 :     BOOST_CHECK_EQUAL(filter.median(), 7);
      37           1 : }
      38             : 
      39           3 : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 1.11