diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 2 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/addr_test.cpp | 41 | ||||
-rw-r--r-- | test/wax_test.cpp | 2 |
4 files changed, 45 insertions, 2 deletions
diff --git a/test/.gitignore b/test/.gitignore index 3d6649c66..28c7c29da 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,3 +1,3 @@ /Makefile /Makefile.in -/wax_test +/*_test diff --git a/test/Makefile.am b/test/Makefile.am index e5b1bc1e1..31deb7391 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,8 +13,10 @@ LDADD = \ $(USRP_UHD_LA) noinst_PROGRAMS = \ + addr_test \ wax_test +addr_test_SOURCES = addr_test.cpp wax_test_SOURCES = wax_test.cpp TESTS = $(noinst_PROGRAMS) 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; +} diff --git a/test/wax_test.cpp b/test/wax_test.cpp index 88c9e0f32..06f17b9b7 100644 --- a/test/wax_test.cpp +++ b/test/wax_test.cpp @@ -74,7 +74,7 @@ int main(void){ std::cout << test_type << std::endl; std::cout << "done" << std::endl; }catch(std::exception const& e){ - std::cout << "Exception: " << e.what() << std::endl; + std::cerr << "Exception: " << e.what() << std::endl; return ~0; } return 0; |