blob: 337d901277476cad40b4260f4a45e6642d11e3eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <vector>
#include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
#include "../util.h"
using namespace std;
BOOST_AUTO_TEST_SUITE(util_tests)
BOOST_AUTO_TEST_CASE(util_MedianFilter)
{
CMedianFilter<int> filter(5, 15);
BOOST_CHECK(filter.median() == 15);
filter.input(20); // [15 20]
BOOST_CHECK(filter.median() == 17);
filter.input(30); // [15 20 30]
BOOST_CHECK(filter.median() == 20);
filter.input(3); // [3 15 20 30]
BOOST_CHECK(filter.median() == 17);
filter.input(7); // [3 7 15 20 30]
BOOST_CHECK(filter.median() == 15);
filter.input(18); // [3 7 18 20 30]
BOOST_CHECK(filter.median() == 18);
filter.input(0); // [0 3 7 18 30]
BOOST_CHECK(filter.median() == 7);
}
BOOST_AUTO_TEST_SUITE_END()
|