summaryrefslogtreecommitdiffstats
path: root/host/tests/convert_test.cpp
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2014-02-04 11:04:07 -0800
committerBen Hilburn <ben.hilburn@ettus.com>2014-02-04 11:04:07 -0800
commit178ac3f1c9950d383c8f64b3df464c0f943c4a23 (patch)
tree318ed621a7b59b7d34d4ce6e4a92f73f0bcef509 /host/tests/convert_test.cpp
parent2718ac110fa931cc29daf7cb3dc5ab6230ee02ab (diff)
downloaduhd-178ac3f1c9950d383c8f64b3df464c0f943c4a23.tar.gz
uhd-178ac3f1c9950d383c8f64b3df464c0f943c4a23.tar.bz2
uhd-178ac3f1c9950d383c8f64b3df464c0f943c4a23.zip
Merging USRP X300 and X310 support!!
Diffstat (limited to 'host/tests/convert_test.cpp')
-rw-r--r--host/tests/convert_test.cpp68
1 files changed, 64 insertions, 4 deletions
diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp
index 4b0226e3d..8ef1e74cc 100644
--- a/host/tests/convert_test.cpp
+++ b/host/tests/convert_test.cpp
@@ -50,8 +50,8 @@ template <typename Range> static void loopback(
const int prio_in = -1,
const int prio_out = -1
){
- //item32 is largest device type
- std::vector<boost::uint32_t> interm(nsamps);
+ //make this buffer large enough for all test types
+ std::vector<boost::uint64_t> interm(nsamps);
std::vector<const void *> input0(1, &input[0]), input1(1, &interm[0]);
std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]);
@@ -148,8 +148,8 @@ static void test_convert_types_for_floats(
BOOST_FOREACH(const int_pair_t &prio, prios){
loopback(nsamps, in_id, out_id, input, output, prio.first, prio.second);
for (size_t i = 0; i < nsamps; i++){
- MY_CHECK_CLOSE(input[i].real(), output[i].real(), value_type(1./32767));
- MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), value_type(1./32767));
+ MY_CHECK_CLOSE(input[i].real(), output[i].real(), value_type(1./(1 << 14)));
+ MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), value_type(1./(1 << 14)));
}
}
}
@@ -207,6 +207,66 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){
}
/***********************************************************************
+ * Test float to/from sc12 conversion loopback
+ **********************************************************************/
+
+BOOST_AUTO_TEST_CASE(test_convert_types_le_sc12_with_fc32){
+ convert::id_type id;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
+ id.output_format = "sc12_item32_le";
+ id.num_outputs = 1;
+
+ //try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1./16);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_convert_types_be_sc12_with_fc32){
+ convert::id_type id;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
+ id.output_format = "sc12_item32_be";
+ id.num_outputs = 1;
+
+ //try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1./16);
+ }
+}
+
+/***********************************************************************
+ * Test float to/from fc32 conversion loopback
+ **********************************************************************/
+
+BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32_with_fc32){
+ convert::id_type id;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
+ id.output_format = "fc32_item32_le";
+ id.num_outputs = 1;
+
+ //try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ test_convert_types_for_floats<fc32_t>(nsamps, id);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32_with_fc32){
+ convert::id_type id;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
+ id.output_format = "fc32_item32_be";
+ id.num_outputs = 1;
+
+ //try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ test_convert_types_for_floats<fc32_t>(nsamps, id);
+ }
+}
+
+/***********************************************************************
* Test float to short conversion loopback
**********************************************************************/
BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){