diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-15 17:49:35 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-15 17:49:35 -0800 |
commit | 379d486ed21aace7f8b37d61f713bdc6088b39e5 (patch) | |
tree | e0093e4ad60ea9f87780c03a5883eded755b51c2 /test/addr_test.cpp | |
parent | 92c76e574773e99d1bfb5c3a833217b8644779f4 (diff) | |
download | uhd-379d486ed21aace7f8b37d61f713bdc6088b39e5.tar.gz uhd-379d486ed21aace7f8b37d61f713bdc6088b39e5.tar.bz2 uhd-379d486ed21aace7f8b37d61f713bdc6088b39e5.zip |
Integrated cppunit into the build system.
Added new test for the usrp dboard stuff.
Diffstat (limited to 'test/addr_test.cpp')
-rw-r--r-- | test/addr_test.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/test/addr_test.cpp b/test/addr_test.cpp index 11fe8c1dd..65792aabc 100644 --- a/test/addr_test.cpp +++ b/test/addr_test.cpp @@ -3,39 +3,38 @@ // #include <usrp_uhd/device_addr.hpp> -#include <iostream> -#include <stdexcept> -#include <boost/format.hpp> -#include <boost/current_function.hpp> +#include <cppunit/extensions/HelperMacros.h> -#define THROW_ASSERT(expr) \ -if (not (expr)){ \ - throw std::runtime_error(str( \ - boost::format("%s %s %s %s") \ - % #expr % BOOST_CURRENT_FUNCTION % __FILE__ % __LINE__ \ - )); \ -} +/*********************************************************************** + * cpp unit setup + **********************************************************************/ +class addr_test : public CppUnit::TestFixture{ + CPPUNIT_TEST_SUITE(addr_test); + CPPUNIT_TEST(test_mac_addr); + CPPUNIT_TEST(test_ip_addr); + CPPUNIT_TEST_SUITE_END(); + +public: + void test_mac_addr(void); + void test_ip_addr(void); +}; -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); +CPPUNIT_TEST_SUITE_REGISTRATION(addr_test); - 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); +void addr_test::test_mac_addr(void){ + 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; + CPPUNIT_ASSERT_EQUAL(mac_addr_str, mac_addr.to_string()); +} - std::cout << "done" << std::endl; - }catch(std::exception const& e){ - std::cerr << "Exception: " << e.what() << std::endl; - return ~0; - } - return 0; +void addr_test::test_ip_addr(void){ + 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; + CPPUNIT_ASSERT_EQUAL(ip_addr_str, ip_addr.to_string()); } |