diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-02-09 23:19:55 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-02-10 16:44:33 -0800 |
commit | 26cc20847cde543e759aa5cee9a27eaa69c5dd9e (patch) | |
tree | eee102333381e2313af59e725d6b7a06b665161f /host/tests | |
parent | f3a004faf7d50cbb5564f5e2f67f54ee07e051dd (diff) | |
download | uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.gz uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.bz2 uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.zip |
uhd: replace BOOST_FOREACH with C++11 range-based for loop
Note: This is the first commit that uses for-range, and range-based
for-loops are now usable for UHD development.
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/addr_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/blockdef_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/convert_test.cpp | 23 | ||||
-rw-r--r-- | host/tests/graph_search_test.cpp | 6 | ||||
-rw-r--r-- | host/tests/nocscript_expr_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/nocscript_ftable_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/nocscript_parser_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/subdev_spec_test.cpp | 1 | ||||
-rw-r--r-- | host/tests/time_spec_test.cpp | 1 |
9 files changed, 14 insertions, 22 deletions
diff --git a/host/tests/addr_test.cpp b/host/tests/addr_test.cpp index 61bb6d049..92863e44f 100644 --- a/host/tests/addr_test.cpp +++ b/host/tests/addr_test.cpp @@ -20,7 +20,6 @@ #include <uhd/types/device_addr.hpp> #include <uhd/usrp/dboard_id.hpp> #include <boost/assign/list_of.hpp> -#include <boost/foreach.hpp> #include <algorithm> #include <iostream> diff --git a/host/tests/blockdef_test.cpp b/host/tests/blockdef_test.cpp index 11ddc4b59..5ca8a2472 100644 --- a/host/tests/blockdef_test.cpp +++ b/host/tests/blockdef_test.cpp @@ -21,7 +21,6 @@ #include <boost/assign/list_of.hpp> #include <boost/test/unit_test.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> #include <uhd/rfnoc/blockdef.hpp> using namespace uhd::rfnoc; diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index dd04dcafc..b4a616133 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -17,7 +17,6 @@ #include <uhd/convert.hpp> #include <boost/test/unit_test.hpp> -#include <boost/foreach.hpp> #include <stdint.h> #include <boost/assign/list_of.hpp> #include <complex> @@ -75,7 +74,7 @@ static void test_convert_types_sc16( ){ //fill the input samples std::vector<sc16_t> input(nsamps), output(nsamps); - BOOST_FOREACH(sc16_t &in, input) in = sc16_t( + for(sc16_t &in: input) in = sc16_t( short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div), short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div) ); @@ -126,7 +125,7 @@ static void test_convert_types_for_floats( //fill the input samples std::vector<data_type> input(nsamps), output(nsamps); - BOOST_FOREACH(data_type &in, input) in = data_type( + for(data_type &in: input) in = data_type( ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale), ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale) ); @@ -145,7 +144,7 @@ static void test_convert_types_for_floats( ; //loopback foreach prio combo (generic vs best) - BOOST_FOREACH(const int_pair_t &prio, prios){ + for(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./(1 << 14))); @@ -284,7 +283,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ const size_t nsamps = 13; std::vector<fc32_t> input(nsamps); - BOOST_FOREACH(fc32_t &in, input) in = fc32_t( + for(fc32_t &in: input) in = fc32_t( (std::rand()/(RAND_MAX/2.0)) - 1, (std::rand()/(RAND_MAX/2.0)) - 1 ); @@ -329,7 +328,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ const size_t nsamps = 13; std::vector<sc16_t> input(nsamps); - BOOST_FOREACH(sc16_t &in, input) in = sc16_t( + for(sc16_t &in: input) in = sc16_t( std::rand()-(RAND_MAX/2), std::rand()-(RAND_MAX/2) ); @@ -424,9 +423,9 @@ static void test_convert_types_u8( ){ //fill the input samples std::vector<uint8_t> input(nsamps), output(nsamps); - BOOST_FOREACH(uint8_t &in, input) in = uint8_t(std::rand() & 0xFF); + for(uint8_t &in: input) in = uint8_t(std::rand() & 0xFF); //uint32_t d = 48; - //BOOST_FOREACH(uint8_t &in, input) in = d++; + //for(uint8_t &in: input) in = d++; //run the loopback and test convert::id_type in_id = id; @@ -464,7 +463,7 @@ static void test_convert_types_s8( ){ //fill the input samples std::vector<int8_t> input(nsamps), output(nsamps); - BOOST_FOREACH(int8_t &in, input) in = int8_t(std::rand() & 0xFF); + for(int8_t &in: input) in = int8_t(std::rand() & 0xFF); //run the loopback and test convert::id_type in_id = id; @@ -502,7 +501,7 @@ static void test_convert_types_s16( ){ //fill the input samples std::vector<int16_t> input(nsamps), output(nsamps); - BOOST_FOREACH(int16_t &in, input) in = int16_t(std::rand() & 0xFFFF); + for(int16_t &in: input) in = int16_t(std::rand() & 0xFFFF); //run the loopback and test convert::id_type in_id = id; @@ -540,7 +539,7 @@ static void test_convert_types_fc32( ){ //fill the input samples std::vector< std::complex<float> > input(nsamps), output(nsamps); - BOOST_FOREACH(fc32_t &in, input) in = fc32_t( + for(fc32_t &in: input) in = fc32_t( (std::rand()/float(RAND_MAX/2)) - 1, (std::rand()/float(RAND_MAX/2)) - 1 ); @@ -581,7 +580,7 @@ static void test_convert_types_f32( ){ //fill the input samples std::vector<float> input(nsamps), output(nsamps); - BOOST_FOREACH(float &in, input) in = float((float(std::rand())/float(RAND_MAX/2)) - 1); + for(float &in: input) in = float((float(std::rand())/float(RAND_MAX/2)) - 1); //run the loopback and test convert::id_type in_id = id; diff --git a/host/tests/graph_search_test.cpp b/host/tests/graph_search_test.cpp index 8c96bb954..d39f767e9 100644 --- a/host/tests/graph_search_test.cpp +++ b/host/tests/graph_search_test.cpp @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(test_linear_downstream_search) std::cout << "size: " << result.size() << std::endl; BOOST_CHECK_EQUAL(result.size(), 1); BOOST_CHECK_EQUAL(result[0]->get_test_id(), "node_B"); - BOOST_FOREACH(const result_node::sptr &node, result) { + for(const result_node::sptr &node: result) { std::cout << node->get_test_id() << std::endl; } } @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(test_multi_iter_downstream_search) // This time, we search for result_node std::vector< result_node::sptr > result = node_A->find_downstream_node<result_node>(); BOOST_REQUIRE(result.size() == 4); - BOOST_FOREACH(const result_node::sptr &node, result) { + for(const result_node::sptr &node: result) { std::cout << node->get_test_id() << std::endl; } } @@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(test_multi_iter_cycle_downstream_search) // This time, we search for result_node std::vector< result_node::sptr > result = node_A->find_downstream_node<result_node>(); BOOST_REQUIRE(result.size() == 4); - BOOST_FOREACH(const result_node::sptr &node, result) { + for(const result_node::sptr &node: result) { std::cout << node->get_test_id() << std::endl; } } diff --git a/host/tests/nocscript_expr_test.cpp b/host/tests/nocscript_expr_test.cpp index f82a613a3..31bbc8725 100644 --- a/host/tests/nocscript_expr_test.cpp +++ b/host/tests/nocscript_expr_test.cpp @@ -18,7 +18,6 @@ #include "../lib/rfnoc/nocscript/function_table.hpp" #include <boost/test/unit_test.hpp> #include <boost/test/floating_point_comparison.hpp> -#include <boost/foreach.hpp> #include <boost/bind.hpp> #include <boost/make_shared.hpp> #include <boost/format.hpp> diff --git a/host/tests/nocscript_ftable_test.cpp b/host/tests/nocscript_ftable_test.cpp index 283245132..546da0c2c 100644 --- a/host/tests/nocscript_ftable_test.cpp +++ b/host/tests/nocscript_ftable_test.cpp @@ -19,7 +19,6 @@ #include <boost/test/unit_test.hpp> #include <boost/test/floating_point_comparison.hpp> #include <boost/assign/list_of.hpp> -#include <boost/foreach.hpp> #include <boost/bind.hpp> #include <boost/make_shared.hpp> #include <algorithm> diff --git a/host/tests/nocscript_parser_test.cpp b/host/tests/nocscript_parser_test.cpp index a9c25977e..c21f40ad6 100644 --- a/host/tests/nocscript_parser_test.cpp +++ b/host/tests/nocscript_parser_test.cpp @@ -21,7 +21,6 @@ #include <boost/test/unit_test.hpp> #include <boost/test/floating_point_comparison.hpp> #include <boost/assign/list_of.hpp> -#include <boost/foreach.hpp> #include <boost/bind.hpp> #include <boost/make_shared.hpp> #include <algorithm> diff --git a/host/tests/subdev_spec_test.cpp b/host/tests/subdev_spec_test.cpp index aa0b9a119..2c4747fa9 100644 --- a/host/tests/subdev_spec_test.cpp +++ b/host/tests/subdev_spec_test.cpp @@ -17,7 +17,6 @@ #include <boost/test/unit_test.hpp> #include <uhd/usrp/subdev_spec.hpp> -#include <boost/foreach.hpp> #include <iostream> BOOST_AUTO_TEST_CASE(test_subdevice_spec){ diff --git a/host/tests/time_spec_test.cpp b/host/tests/time_spec_test.cpp index 76dfb1930..9ff89ab0e 100644 --- a/host/tests/time_spec_test.cpp +++ b/host/tests/time_spec_test.cpp @@ -17,7 +17,6 @@ #include <boost/test/unit_test.hpp> #include <uhd/types/time_spec.hpp> -#include <boost/foreach.hpp> #include <boost/thread.hpp> //sleep #include <iostream> #include <iomanip> |