summaryrefslogtreecommitdiffstats
path: root/test/addr_test.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-01-13 19:35:38 -0800
committerJosh Blum <josh@joshknows.com>2010-01-13 19:35:38 -0800
commitb52880892d1a85203e58cdb049877e7ae4c16663 (patch)
tree5ef463525c9633bfbe7eadb4b3da5b1188bb5142 /test/addr_test.cpp
parent24d95c3f2cea168d1d314af29839d88cc16d3c7f (diff)
downloaduhd-b52880892d1a85203e58cdb049877e7ae4c16663.tar.gz
uhd-b52880892d1a85203e58cdb049877e7ae4c16663.tar.bz2
uhd-b52880892d1a85203e58cdb049877e7ae4c16663.zip
Added strict compiler flags.
Made changes to meet compilation. Added test to verify ip and mac addr code.
Diffstat (limited to 'test/addr_test.cpp')
-rw-r--r--test/addr_test.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/addr_test.cpp b/test/addr_test.cpp
new file mode 100644
index 000000000..11fe8c1dd
--- /dev/null
+++ b/test/addr_test.cpp
@@ -0,0 +1,41 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+
+#include <usrp_uhd/device_addr.hpp>
+#include <iostream>
+#include <stdexcept>
+#include <boost/format.hpp>
+#include <boost/current_function.hpp>
+
+#define THROW_ASSERT(expr) \
+if (not (expr)){ \
+ throw std::runtime_error(str( \
+ boost::format("%s %s %s %s") \
+ % #expr % BOOST_CURRENT_FUNCTION % __FILE__ % __LINE__ \
+ )); \
+}
+
+int main(void){
+ try{
+ std::cout << "Testing mac addr:" << std::endl;
+ const std::string mac_addr_str("00:01:23:45:67:89");
+ usrp_uhd::mac_addr_t mac_addr(mac_addr_str);
+ std::cout << "Input: " << mac_addr_str << std::endl;
+ std::cout << "Output: " << mac_addr << std::endl;
+ THROW_ASSERT(mac_addr.to_string() == mac_addr_str);
+
+ std::cout << "Testing ip addr:" << std::endl;
+ const std::string ip_addr_str("192.168.1.10");
+ usrp_uhd::ip_addr_t ip_addr(ip_addr_str);
+ std::cout << "Input: " << ip_addr_str << std::endl;
+ std::cout << "Output: " << ip_addr << std::endl;
+ THROW_ASSERT(ip_addr.to_string() == ip_addr_str);
+
+ std::cout << "done" << std::endl;
+ }catch(std::exception const& e){
+ std::cerr << "Exception: " << e.what() << std::endl;
+ return ~0;
+ }
+ return 0;
+}