diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-09-29 10:50:40 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-09-29 10:50:40 -0700 |
commit | 9a7e5ed3b000a9788f3e3e2a145c4504473d812e (patch) | |
tree | a555362fbbf25d6f26f5ee9f048555bb0864d2f2 /src/test | |
parent | 7dd4001b40b65b66ba5d47e628f10253ccb5d99c (diff) | |
parent | 20091df725e56376f6df0f71d19c63a34a5bf71d (diff) |
Merge pull request #539 from laanwj/qt2
Qt GUI updates
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/util_tests.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp new file mode 100644 index 0000000000..337d901277 --- /dev/null +++ b/src/test/util_tests.cpp @@ -0,0 +1,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() |