diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-05-09 17:10:01 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-05-09 17:10:01 -0700 |
commit | 70d8d2a7e099eb7485cb58871dc79e91f3e9f378 (patch) | |
tree | 4d76ce90bc1e70c81b6ab82455b42ed24c441880 /host/tests/ranges_test.cpp | |
parent | 36be5216c237b15dbd00c17f33ac320192306882 (diff) | |
download | uhd-70d8d2a7e099eb7485cb58871dc79e91f3e9f378.tar.gz uhd-70d8d2a7e099eb7485cb58871dc79e91f3e9f378.tar.bz2 uhd-70d8d2a7e099eb7485cb58871dc79e91f3e9f378.zip |
tests: Add unit test for meta_range_t ctors
Diffstat (limited to 'host/tests/ranges_test.cpp')
-rw-r--r-- | host/tests/ranges_test.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/host/tests/ranges_test.cpp b/host/tests/ranges_test.cpp index 4f5b9e543..fd6336a55 100644 --- a/host/tests/ranges_test.cpp +++ b/host/tests/ranges_test.cpp @@ -11,7 +11,8 @@ using namespace uhd; -static const double tolerance = 0.001; +static const double tolerance = 0.001; // % + BOOST_AUTO_TEST_CASE(test_ranges_bounds){ meta_range_t mr; @@ -46,6 +47,23 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip){ BOOST_CHECK_CLOSE(mr.clip(50.9, true), 51.0, tolerance); } +BOOST_AUTO_TEST_CASE(test_meta_range_t_ctor){ + meta_range_t mr1(0.0, 10.0, 1.0); + BOOST_CHECK_CLOSE(mr1.clip(5.0), 5.0, tolerance); + BOOST_CHECK_CLOSE(mr1.clip(11.0), 10.0, tolerance); + BOOST_CHECK_CLOSE(mr1.clip(5.1, true), 5.0, tolerance); + + meta_range_t mr2(0.0, 10.0); + BOOST_CHECK_CLOSE(mr2.clip(5.0), 5.0, tolerance); + BOOST_CHECK_CLOSE(mr2.clip(11.0), 10.0, tolerance); + BOOST_CHECK_CLOSE(mr2.clip(5.1, true), 5.1, tolerance); + + meta_range_t mr3(mr2.begin(), mr2.end()); + BOOST_CHECK_CLOSE(mr3.clip(5.0), 5.0, tolerance); + BOOST_CHECK_CLOSE(mr3.clip(11.0), 10.0, tolerance); + BOOST_CHECK_CLOSE(mr3.clip(5.1, true), 5.1, tolerance); +} + BOOST_AUTO_TEST_CASE(test_ranges_clip2){ meta_range_t mr; mr.push_back(range_t(1.)); |