aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/gain_group_test.cpp
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-01-14 10:35:25 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-16 11:40:23 -0800
commit967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch)
tree8a24954b54d1546dc8049a17e485adb0a605f74f /host/tests/gain_group_test.cpp
parentaafe4e8b742a0e21d3818f21f34e3c8613132530 (diff)
downloaduhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file.
Diffstat (limited to 'host/tests/gain_group_test.cpp')
-rw-r--r--host/tests/gain_group_test.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/host/tests/gain_group_test.cpp b/host/tests/gain_group_test.cpp
index b8c15b479..2608f292d 100644
--- a/host/tests/gain_group_test.cpp
+++ b/host/tests/gain_group_test.cpp
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/utils/gain_group.hpp>
#include <boost/bind.hpp>
#include <boost/math/special_functions/round.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#define rint(x) boost::math::iround(x)
@@ -18,56 +18,63 @@ using namespace uhd;
/***********************************************************************
* Define gain element classes with needed functions
**********************************************************************/
-class gain_element1{
+class gain_element1
+{
public:
-
- gain_range_t get_range(void){
+ gain_range_t get_range(void)
+ {
return gain_range_t(0, 90, 1);
}
- double get_value(void){
+ double get_value(void)
+ {
return _gain;
}
- void set_value(double gain){
+ void set_value(double gain)
+ {
double step = get_range().step();
- _gain = step*rint(gain/step);
+ _gain = step * rint(gain / step);
}
private:
double _gain;
};
-class gain_element2{
+class gain_element2
+{
public:
-
- gain_range_t get_range(void){
+ gain_range_t get_range(void)
+ {
return gain_range_t(-20, 10, 0.1);
}
- double get_value(void){
+ double get_value(void)
+ {
return _gain;
}
- void set_value(double gain){
+ void set_value(double gain)
+ {
double step = get_range().step();
- _gain = step*rint(gain/step);
+ _gain = step * rint(gain / step);
}
private:
double _gain;
};
-//create static instances of gain elements to be shared by the tests
+// create static instances of gain elements to be shared by the tests
static gain_element1 g1;
static gain_element2 g2;
-static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0){
- //create instance of gain group
+static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0)
+{
+ // create instance of gain group
gain_fcns_t gain_fcns;
gain_group::sptr gg(gain_group::make());
- //load gain group with function sets
+ // load gain group with function sets
gain_fcns.get_range = boost::bind(&gain_element1::get_range, &g1);
gain_fcns.get_value = boost::bind(&gain_element1::get_value, &g1);
gain_fcns.set_value = boost::bind(&gain_element1::set_value, &g1, _1);
@@ -86,10 +93,11 @@ static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0){
**********************************************************************/
static const double tolerance = 0.001;
-BOOST_AUTO_TEST_CASE(test_gain_group_overall){
+BOOST_AUTO_TEST_CASE(test_gain_group_overall)
+{
gain_group::sptr gg = get_gain_group();
- //test the overall stuff
+ // test the overall stuff
gg->set_value(80);
BOOST_CHECK_CLOSE(gg->get_value(), 80.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().start(), -20.0, tolerance);
@@ -97,16 +105,17 @@ BOOST_AUTO_TEST_CASE(test_gain_group_overall){
BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
}
-BOOST_AUTO_TEST_CASE(test_gain_group_priority){
+BOOST_AUTO_TEST_CASE(test_gain_group_priority)
+{
gain_group::sptr gg = get_gain_group(0, 1);
- //test the overall stuff
+ // test the overall stuff
gg->set_value(80);
BOOST_CHECK_CLOSE(gg->get_value(), 80.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().start(), -20.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().stop(), 100.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
- //test the the higher priority gain got filled first (gain 2)
+ // test the the higher priority gain got filled first (gain 2)
BOOST_CHECK_CLOSE(g2.get_value(), g2.get_range().stop(), tolerance);
}