2010-08-05 18:50:30 +00:00
|
|
|
//
|
2011-03-24 01:48:30 +00:00
|
|
|
// Copyright 2010-2011 Ettus Research LLC
|
2018-02-19 23:30:32 +00:00
|
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
2010-08-05 18:50:30 +00:00
|
|
|
//
|
2018-02-19 23:30:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2010-08-05 18:50:30 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <uhd/usrp/subdev_spec.hpp>
|
2019-01-14 18:35:25 +00:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2010-08-05 18:50:30 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
BOOST_AUTO_TEST_CASE(test_subdevice_spec)
|
|
|
|
|
{
|
2010-08-05 18:50:30 +00:00
|
|
|
std::cout << "Testing subdevice specification..." << std::endl;
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
// load the subdev spec with something
|
2010-08-05 18:50:30 +00:00
|
|
|
uhd::usrp::subdev_spec_t sd_spec;
|
2010-08-05 23:41:51 +00:00
|
|
|
sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("A", "AB"));
|
|
|
|
|
sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "AB"));
|
2010-08-05 18:50:30 +00:00
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
// create a subdev_spec with something different
|
2017-05-10 01:36:02 +00:00
|
|
|
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"));
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
// convert to and from args string
|
2010-08-05 18:50:30 +00:00
|
|
|
std::cout << "Pretty Print: " << std::endl << sd_spec.to_pp_string();
|
|
|
|
|
std::string markup_str = sd_spec.to_string();
|
|
|
|
|
std::cout << "Markup String: " << markup_str << std::endl;
|
|
|
|
|
uhd::usrp::subdev_spec_t new_sd_spec(markup_str);
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
// they should be the same size
|
2010-08-05 18:50:30 +00:00
|
|
|
BOOST_REQUIRE_EQUAL(sd_spec.size(), new_sd_spec.size());
|
|
|
|
|
|
2019-01-14 18:35:25 +00:00
|
|
|
// the contents should match
|
|
|
|
|
for (size_t i = 0; i < sd_spec.size(); i++) {
|
2010-08-05 23:41:51 +00:00
|
|
|
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);
|
2017-05-10 01:36:02 +00:00
|
|
|
|
|
|
|
|
BOOST_CHECK(sd_spec.at(i) == new_sd_spec.at(i));
|
|
|
|
|
BOOST_CHECK(sd_spec.at(i) != diff_sd_spec.at(i));
|
2010-08-05 18:50:30 +00:00
|
|
|
}
|
|
|
|
|
}
|