aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/error_test.cpp21
-rw-r--r--host/tests/tune_helper_test.cpp22
-rw-r--r--host/tests/wax_test.cpp4
3 files changed, 27 insertions, 20 deletions
diff --git a/host/tests/error_test.cpp b/host/tests/error_test.cpp
index c76a15ab7..983f0150c 100644
--- a/host/tests/error_test.cpp
+++ b/host/tests/error_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -16,19 +16,30 @@
//
#include <boost/test/unit_test.hpp>
-#include <uhd/utils/assert.hpp>
+#include <uhd/exception.hpp>
+#include <uhd/utils/assert_has.hpp>
#include <vector>
#include <iostream>
+BOOST_AUTO_TEST_CASE(test_exception_methods){
+ try{
+ throw uhd::assertion_error("your assertion failed: 1 != 2");
+ }
+ catch(const uhd::exception &e){
+ std::cout << "what: " << e.what() << std::endl;
+ std::cout << "code: " << e.code() << std::endl;
+ }
+}
+
BOOST_AUTO_TEST_CASE(test_assert_has){
std::vector<int> vec;
vec.push_back(2);
vec.push_back(3);
vec.push_back(5);
- //verify the std::has utility
- BOOST_CHECK(std::has(vec, 2));
- BOOST_CHECK(not std::has(vec, 1));
+ //verify the uhd::has utility
+ BOOST_CHECK(uhd::has(vec, 2));
+ BOOST_CHECK(not uhd::has(vec, 1));
std::cout << "The output of the assert_has error:" << std::endl;
try{
diff --git a/host/tests/tune_helper_test.cpp b/host/tests/tune_helper_test.cpp
index 735e7e948..aabaaaf6e 100644
--- a/host/tests/tune_helper_test.cpp
+++ b/host/tests/tune_helper_test.cpp
@@ -153,10 +153,6 @@ private:
val = _freq_shift;
return;
- case DSP_PROP_FREQ_SHIFT_NAMES:
- val = prop_names_t(1, "");
- return;
-
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -190,12 +186,12 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_rx){
dummy_dsp dsp(100e6);
std::cout << "Testing tune helper RX automatic IF offset" << std::endl;
- tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.3451e9);
+ tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.3451e9);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.345e9, tolerance);
BOOST_CHECK_CLOSE(tr.actual_dsp_freq, -100e3, tolerance);
- double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0);
+ double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link());
BOOST_CHECK_CLOSE(freq_derived, 2.3451e9, tolerance);
}
@@ -204,12 +200,12 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_tx){
dummy_dsp dsp(100e6);
std::cout << "Testing tune helper TX automatic IF offset" << std::endl;
- tune_result_t tr = tune_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.3451e9);
+ tune_result_t tr = tune_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.3451e9);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.345e9, tolerance);
BOOST_CHECK_CLOSE(tr.actual_dsp_freq, 100e3, tolerance);
- double freq_derived = derive_freq_from_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0);
+ double freq_derived = derive_freq_from_tx_subdev_and_dsp(subdev.get_link(), dsp.get_link());
BOOST_CHECK_CLOSE(freq_derived, 2.3451e9, tolerance);
}
@@ -218,12 +214,12 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_rx_nyquist){
dummy_dsp dsp(100e6);
std::cout << "Testing tune helper RX dummy basic board" << std::endl;
- tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 55e6);
+ tune_result_t tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 55e6);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 0.0, tolerance);
BOOST_CHECK_CLOSE(tr.actual_dsp_freq, 45e6, tolerance);
- double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0);
+ double freq_derived = derive_freq_from_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link());
BOOST_CHECK_CLOSE(freq_derived, -45e6, tolerance);
}
@@ -235,21 +231,21 @@ BOOST_AUTO_TEST_CASE(test_tune_helper_rx_lo_off){
std::cout << "Testing tune helper RX automatic LO offset B >> fs" << std::endl;
subdev[SUBDEV_PROP_BANDWIDTH] = double(40e6);
dsp[DSP_PROP_HOST_RATE] = double(4e6);
- tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.45e9);
+ tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.45e9);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.45e9+4e6/2, tolerance);
std::cout << "Testing tune helper RX automatic LO offset B > fs" << std::endl;
subdev[SUBDEV_PROP_BANDWIDTH] = double(40e6);
dsp[DSP_PROP_HOST_RATE] = double(25e6);
- tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.45e9);
+ tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.45e9);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.45e9+(40e6-25e6)/2, tolerance);
std::cout << "Testing tune helper RX automatic LO offset B < fs" << std::endl;
subdev[SUBDEV_PROP_BANDWIDTH] = double(20e6);
dsp[DSP_PROP_HOST_RATE] = double(25e6);
- tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 0, 2.45e9);
+ tr = tune_rx_subdev_and_dsp(subdev.get_link(), dsp.get_link(), 2.45e9);
std::cout << tr.to_pp_string() << std::endl;
BOOST_CHECK_CLOSE(tr.actual_inter_freq, 2.45e9, tolerance);
}
diff --git a/host/tests/wax_test.cpp b/host/tests/wax_test.cpp
index 731f470ed..18730e0c2 100644
--- a/host/tests/wax_test.cpp
+++ b/host/tests/wax_test.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ enum opt_b_t{OPTION_B_0, OPTION_B_1};
BOOST_AUTO_TEST_CASE(test_enums){
wax::obj opta = OPTION_A_0;
- BOOST_CHECK_THROW(opta.as<opt_b_t>(), wax::bad_cast);
+ BOOST_CHECK_THROW(opta.as<opt_b_t>(), std::exception);
BOOST_CHECK_EQUAL(opta.as<opt_a_t>(), OPTION_A_0);
}