From 5a08586157ed23ebc1344583d21fa56fb27cbe52 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 29 Mar 2010 13:14:57 -0700 Subject: unit test for device addr --- host/test/addr_test.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'host/test/addr_test.cpp') diff --git a/host/test/addr_test.cpp b/host/test/addr_test.cpp index a75804949..a5d2d4c06 100644 --- a/host/test/addr_test.cpp +++ b/host/test/addr_test.cpp @@ -17,6 +17,10 @@ #include #include +#include +#include +#include +#include #include BOOST_AUTO_TEST_CASE(test_mac_addr){ @@ -27,3 +31,37 @@ BOOST_AUTO_TEST_CASE(test_mac_addr){ std::cout << "Output: " << mac_addr.to_string() << std::endl; BOOST_CHECK_EQUAL(mac_addr_str, mac_addr.to_string()); } + +BOOST_AUTO_TEST_CASE(test_device_addr){ + std::cout << "Testing device addr..." << std::endl; + + //load the device address with something + uhd::device_addr_t dev_addr; + dev_addr["key1"] = "val1"; + dev_addr["key2"] = "val2"; + + //convert to and from args string + std::cout << "Pretty Print: " << std::endl << dev_addr.to_string(); + std::string args_str = dev_addr.to_args_str(); + std::cout << "Args String: " << args_str << std::endl; + uhd::device_addr_t new_dev_addr = uhd::device_addr_t::from_args_str(args_str); + + //they should be the same size + BOOST_CHECK_EQUAL(dev_addr.size(), new_dev_addr.size()); + + //the keys should match + std::vector old_dev_addr_keys = dev_addr.get_keys(); + std::vector new_dev_addr_keys = new_dev_addr.get_keys(); + BOOST_CHECK_EQUAL_COLLECTIONS( + old_dev_addr_keys.begin(), old_dev_addr_keys.end(), + new_dev_addr_keys.begin(), new_dev_addr_keys.end() + ); + + //the vals should match + std::vector old_dev_addr_vals = dev_addr.get_vals(); + std::vector new_dev_addr_vals = new_dev_addr.get_vals(); + BOOST_CHECK_EQUAL_COLLECTIONS( + old_dev_addr_vals.begin(), old_dev_addr_vals.end(), + new_dev_addr_vals.begin(), new_dev_addr_vals.end() + ); +} -- cgit v1.2.3