From 70d8d2a7e099eb7485cb58871dc79e91f3e9f378 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 9 May 2018 17:10:01 -0700 Subject: tests: Add unit test for meta_range_t ctors --- host/tests/ranges_test.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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.)); -- cgit v1.2.3