aboutsummaryrefslogtreecommitdiffstats
path: root/host/test/addr_test.cpp
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-04-01 12:44:19 +0000
committerPhilip Balister <philip@opensdr.com>2010-04-01 12:44:19 +0000
commit93572731923e43bbb34a12db41170e56376ab03b (patch)
treea46c53d1695a211dac39e46abf60a8f517e8d287 /host/test/addr_test.cpp
parent930755fce1e5d22a5ede0459dccd6c9501fc642c (diff)
parent03be4d0673c5e0f597db7d27f535956a591bbeb7 (diff)
downloaduhd-93572731923e43bbb34a12db41170e56376ab03b.tar.gz
uhd-93572731923e43bbb34a12db41170e56376ab03b.tar.bz2
uhd-93572731923e43bbb34a12db41170e56376ab03b.zip
Merge branch 'usrp_e' of git@ettus.sourcerepo.com:ettus/uhd into usrp_e
Diffstat (limited to 'host/test/addr_test.cpp')
-rw-r--r--host/test/addr_test.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/host/test/addr_test.cpp b/host/test/addr_test.cpp
index 148aee015..a5d2d4c06 100644
--- a/host/test/addr_test.cpp
+++ b/host/test/addr_test.cpp
@@ -16,13 +16,52 @@
//
#include <boost/test/unit_test.hpp>
-#include <uhd/device_addr.hpp>
+#include <uhd/types/mac_addr.hpp>
+#include <uhd/types/device_addr.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/foreach.hpp>
+#include <algorithm>
+#include <iostream>
BOOST_AUTO_TEST_CASE(test_mac_addr){
std::cout << "Testing mac addr..." << std::endl;
const std::string mac_addr_str("00:01:23:45:67:89");
- uhd::mac_addr_t mac_addr(mac_addr_str);
+ uhd::mac_addr_t mac_addr = uhd::mac_addr_t::from_string(mac_addr_str);
std::cout << "Input: " << mac_addr_str << std::endl;
- std::cout << "Output: " << mac_addr << std::endl;
+ 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<std::string> old_dev_addr_keys = dev_addr.get_keys();
+ std::vector<std::string> 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<std::string> old_dev_addr_vals = dev_addr.get_vals();
+ std::vector<std::string> 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()
+ );
+}