From 2c0f1098351d6c0763d985c2085ec676a7992e2d Mon Sep 17 00:00:00 2001 From: Paul David Date: Tue, 9 May 2017 21:36:02 -0400 Subject: Types: Added equality/inquality operators to support Boost.Python additions - Added to subdev_spec_pair_t - Added to range_t - Added tests for the inequalities --- host/tests/ranges_test.cpp | 9 +++++++++ host/tests/subdev_spec_test.cpp | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'host/tests') diff --git a/host/tests/ranges_test.cpp b/host/tests/ranges_test.cpp index 85bb4c3c4..49607b9a3 100644 --- a/host/tests/ranges_test.cpp +++ b/host/tests/ranges_test.cpp @@ -68,3 +68,12 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip2){ BOOST_CHECK_CLOSE(mr.clip(3.1, true), 3., tolerance); BOOST_CHECK_CLOSE(mr.clip(4., true), 3., tolerance); } + +BOOST_AUTO_TEST_CASE(test_ranges_compare){ + range_t range(1); + range_t n_range(1); + range_t d_range(2); + + BOOST_CHECK(range == n_range); + BOOST_CHECK(range != d_range); +} diff --git a/host/tests/subdev_spec_test.cpp b/host/tests/subdev_spec_test.cpp index 2c4747fa9..81f86380b 100644 --- a/host/tests/subdev_spec_test.cpp +++ b/host/tests/subdev_spec_test.cpp @@ -27,6 +27,11 @@ BOOST_AUTO_TEST_CASE(test_subdevice_spec){ sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("A", "AB")); sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "AB")); + //create a subdev_spec with something different + uhd::usrp::subdev_spec_t diff_sd_spec; + diff_sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "BA")); + diff_sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "BA")); + //convert to and from args string std::cout << "Pretty Print: " << std::endl << sd_spec.to_pp_string(); std::string markup_str = sd_spec.to_string(); @@ -40,5 +45,8 @@ BOOST_AUTO_TEST_CASE(test_subdevice_spec){ for (size_t i = 0; i < sd_spec.size(); i++){ BOOST_CHECK_EQUAL(sd_spec.at(i).db_name, new_sd_spec.at(i).db_name); BOOST_CHECK_EQUAL(sd_spec.at(i).sd_name, new_sd_spec.at(i).sd_name); + + BOOST_CHECK(sd_spec.at(i) == new_sd_spec.at(i)); + BOOST_CHECK(sd_spec.at(i) != diff_sd_spec.at(i)); } } -- cgit v1.2.3