diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 10:35:25 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-16 11:40:23 -0800 |
commit | 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch) | |
tree | 8a24954b54d1546dc8049a17e485adb0a605f74f /host/tests/constrained_device_args_test.cpp | |
parent | aafe4e8b742a0e21d3818f21f34e3c8613132530 (diff) | |
download | uhd-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/constrained_device_args_test.cpp')
-rw-r--r-- | host/tests/constrained_device_args_test.cpp | 146 |
1 files changed, 69 insertions, 77 deletions
diff --git a/host/tests/constrained_device_args_test.cpp b/host/tests/constrained_device_args_test.cpp index 318315739..2fe7e5c16 100644 --- a/host/tests/constrained_device_args_test.cpp +++ b/host/tests/constrained_device_args_test.cpp @@ -4,101 +4,93 @@ // SPDX-License-Identifier: GPL-3.0-or-later // -#include <boost/test/unit_test.hpp> #include <uhdlib/usrp/constrained_device_args.hpp> +#include <boost/test/unit_test.hpp> #include <iostream> using uhd::usrp::constrained_device_args_t; namespace { - enum test_enum_t { VALUE1, VALUE2, VALUE3=4 }; +enum test_enum_t { VALUE1, VALUE2, VALUE3 = 4 }; - static constexpr double MAX_DOUBLE_ARG = 1e6; - static constexpr double MIN_DOUBLE_ARG = 0.125; +static constexpr double MAX_DOUBLE_ARG = 1e6; +static constexpr double MIN_DOUBLE_ARG = 0.125; - static constexpr double DEFAULT_DOUBLE_ARG = 2.25; - static constexpr size_t DEFAULT_SIZE_T_ARG = 42; - static constexpr bool DEFAULT_BOOL_ARG = true; - static constexpr test_enum_t DEFAULT_ENUM_ARG = VALUE1; +static constexpr double DEFAULT_DOUBLE_ARG = 2.25; +static constexpr size_t DEFAULT_SIZE_T_ARG = 42; +static constexpr bool DEFAULT_BOOL_ARG = true; +static constexpr test_enum_t DEFAULT_ENUM_ARG = VALUE1; - class test_device_args_t : public constrained_device_args_t +class test_device_args_t : public constrained_device_args_t +{ +public: + test_device_args_t() {} + test_device_args_t(const std::string& dev_args) { - public: - test_device_args_t() {} - test_device_args_t(const std::string& dev_args) { parse(dev_args); } + parse(dev_args); + } - double get_double_arg() const { - return _double_arg.get(); - } - size_t get_size_t_arg() const { - return _size_t_arg.get(); - } - bool get_bool_arg() const { - return _bool_arg.get(); - } - test_enum_t get_enum_arg() const { - return _enum_arg.get(); - } + double get_double_arg() const + { + return _double_arg.get(); + } + size_t get_size_t_arg() const + { + return _size_t_arg.get(); + } + bool get_bool_arg() const + { + return _bool_arg.get(); + } + test_enum_t get_enum_arg() const + { + return _enum_arg.get(); + } - inline virtual std::string to_string() const { - return _double_arg.to_string() + ", " + - _size_t_arg.to_string() + ", " + - _bool_arg.to_string() + ", " + - _enum_arg.to_string(); - } - private: - virtual void _parse(const uhd::device_addr_t& dev_args) { - if (dev_args.has_key(_double_arg.key())) - _double_arg.parse(dev_args[_double_arg.key()]); - if (dev_args.has_key(_size_t_arg.key())) - _size_t_arg.parse(dev_args[_size_t_arg.key()]); - if (dev_args.has_key(_bool_arg.key())) - _bool_arg.parse(dev_args[_bool_arg.key()]); - if (dev_args.has_key(_enum_arg.key())) - _enum_arg.parse(dev_args[_enum_arg.key()]); - _enforce_range(_double_arg, MIN_DOUBLE_ARG, MAX_DOUBLE_ARG); - } + inline virtual std::string to_string() const + { + return _double_arg.to_string() + ", " + _size_t_arg.to_string() + ", " + + _bool_arg.to_string() + ", " + _enum_arg.to_string(); + } - constrained_device_args_t::num_arg<double> _double_arg - {"double_arg", DEFAULT_DOUBLE_ARG}; - constrained_device_args_t::num_arg<size_t> _size_t_arg - {"size_t_arg", DEFAULT_SIZE_T_ARG}; - constrained_device_args_t::bool_arg _bool_arg - {"bool_arg", DEFAULT_BOOL_ARG}; - constrained_device_args_t::enum_arg<test_enum_t> _enum_arg - {"enum_arg", DEFAULT_ENUM_ARG, - {{"value1", VALUE1}, {"value2", VALUE2}, {"VALUE3", VALUE3}}}; - }; +private: + virtual void _parse(const uhd::device_addr_t& dev_args) + { + if (dev_args.has_key(_double_arg.key())) + _double_arg.parse(dev_args[_double_arg.key()]); + if (dev_args.has_key(_size_t_arg.key())) + _size_t_arg.parse(dev_args[_size_t_arg.key()]); + if (dev_args.has_key(_bool_arg.key())) + _bool_arg.parse(dev_args[_bool_arg.key()]); + if (dev_args.has_key(_enum_arg.key())) + _enum_arg.parse(dev_args[_enum_arg.key()]); + _enforce_range(_double_arg, MIN_DOUBLE_ARG, MAX_DOUBLE_ARG); + } -} + constrained_device_args_t::num_arg<double> _double_arg{ + "double_arg", DEFAULT_DOUBLE_ARG}; + constrained_device_args_t::num_arg<size_t> _size_t_arg{ + "size_t_arg", DEFAULT_SIZE_T_ARG}; + constrained_device_args_t::bool_arg _bool_arg{"bool_arg", DEFAULT_BOOL_ARG}; + constrained_device_args_t::enum_arg<test_enum_t> _enum_arg{"enum_arg", + DEFAULT_ENUM_ARG, + {{"value1", VALUE1}, {"value2", VALUE2}, {"VALUE3", VALUE3}}}; +}; -BOOST_AUTO_TEST_CASE(test_constrained_device_args) { +} // namespace + +BOOST_AUTO_TEST_CASE(test_constrained_device_args) +{ test_device_args_t test_dev_args("double_arg=3.5,bool_arg=0,foo=bar"); BOOST_CHECK_EQUAL(test_dev_args.get_double_arg(), 3.5); - BOOST_CHECK_EQUAL( - test_dev_args.get_size_t_arg(), - DEFAULT_SIZE_T_ARG - ); + BOOST_CHECK_EQUAL(test_dev_args.get_size_t_arg(), DEFAULT_SIZE_T_ARG); BOOST_CHECK_EQUAL(test_dev_args.get_bool_arg(), false); - BOOST_CHECK_EQUAL( - test_dev_args.get_enum_arg(), - DEFAULT_ENUM_ARG - ); - BOOST_REQUIRE_THROW( - test_dev_args.parse("double_arg=2e6"), - uhd::value_error - ); // Note: test_dev_args is now in a bad state until we fix it! - test_dev_args.parse("double_arg=2.6"), - test_dev_args.parse("enum_arg=vaLue2"); - BOOST_CHECK_EQUAL( - test_dev_args.get_enum_arg(), - VALUE2 - ); + BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), DEFAULT_ENUM_ARG); + BOOST_REQUIRE_THROW(test_dev_args.parse("double_arg=2e6"), + uhd::value_error); // Note: test_dev_args is now in a bad state until we fix it! + test_dev_args.parse("double_arg=2.6"), test_dev_args.parse("enum_arg=vaLue2"); + BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), VALUE2); test_dev_args.parse("enum_arg=VALUE3"); - BOOST_CHECK_EQUAL( - test_dev_args.get_enum_arg(), - VALUE3 - ); + BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), VALUE3); } - |