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/config_parser_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/config_parser_test.cpp')
-rw-r--r-- | host/tests/config_parser_test.cpp | 109 |
1 files changed, 42 insertions, 67 deletions
diff --git a/host/tests/config_parser_test.cpp b/host/tests/config_parser_test.cpp index ef1686a11..2016776a7 100644 --- a/host/tests/config_parser_test.cpp +++ b/host/tests/config_parser_test.cpp @@ -5,93 +5,68 @@ // #include <uhdlib/utils/config_parser.hpp> -#include <boost/test/unit_test.hpp> #include <boost/assign/list_of.hpp> -#include <fstream> +#include <boost/test/unit_test.hpp> #include <cstdio> +#include <fstream> const std::string INI1_FILENAME = "test1.ini"; -const std::string INI1 = - "[section1]\n" - "key1=value1\n" - "key2=4\n" - "\n" - "; This is a comment\n" - "[section2]\n" - "key3=value with spaces\n" - "key4= leading and trailing spaces \n" -; +const std::string INI1 = "[section1]\n" + "key1=value1\n" + "key2=4\n" + "\n" + "; This is a comment\n" + "[section2]\n" + "key3=value with spaces\n" + "key4= leading and trailing spaces \n"; const std::string INI2_FILENAME = "test2.ini"; -const std::string INI2 = - "[section2]\n" - "key3=value with even more spaces\n" - "\n" - "[section3]\n" - "key4=\"with quotes\"\n"; +const std::string INI2 = "[section2]\n" + "key3=value with even more spaces\n" + "\n" + "[section3]\n" + "key4=\"with quotes\"\n"; namespace { - //! Create files that can be read by the CUT - void make_config_parsers() - { - std::ofstream ini1(INI1_FILENAME); - ini1 << INI1 << std::endl; - ini1.close(); - std::ofstream ini2(INI2_FILENAME); - ini2 << INI2 << std::endl; - ini2.close(); - } +//! Create files that can be read by the CUT +void make_config_parsers() +{ + std::ofstream ini1(INI1_FILENAME); + ini1 << INI1 << std::endl; + ini1.close(); + std::ofstream ini2(INI2_FILENAME); + ini2 << INI2 << std::endl; + ini2.close(); +} - //! Tidy up after us - void cleanup_config_parsers() - { - std::remove(INI1_FILENAME.c_str()); - std::remove(INI2_FILENAME.c_str()); - } +//! Tidy up after us +void cleanup_config_parsers() +{ + std::remove(INI1_FILENAME.c_str()); + std::remove(INI2_FILENAME.c_str()); } +} // namespace -BOOST_AUTO_TEST_CASE(test_config_parser){ +BOOST_AUTO_TEST_CASE(test_config_parser) +{ make_config_parsers(); uhd::config_parser I(INI1_FILENAME); BOOST_CHECK_EQUAL(I.sections().size(), 2); BOOST_CHECK_EQUAL(I.options("section1").size(), 2); + BOOST_CHECK_EQUAL(I.get<std::string>("section1", "key1"), "value1"); + BOOST_CHECK_EQUAL(I.get<int>("section1", "key2"), 4); + BOOST_CHECK_EQUAL(I.get<std::string>("section2", "key3"), "value with spaces"); BOOST_CHECK_EQUAL( - I.get<std::string>("section1", "key1"), - "value1" - ); + I.get<std::string>("section2", "key4"), "leading and trailing spaces"); BOOST_CHECK_EQUAL( - I.get<int>("section1", "key2"), - 4 - ); - BOOST_CHECK_EQUAL( - I.get<std::string>("section2", "key3"), - "value with spaces" - ); - BOOST_CHECK_EQUAL( - I.get<std::string>("section2", "key4"), - "leading and trailing spaces" - ); - BOOST_CHECK_EQUAL( - I.get<std::string>("section2", "non_existent_key", "default"), - "default" - ); + I.get<std::string>("section2", "non_existent_key", "default"), "default"); BOOST_REQUIRE_THROW( - I.get<std::string>("section2", "non_existent_key"), - uhd::key_error - ); + I.get<std::string>("section2", "non_existent_key"), uhd::key_error); I.read_file(INI2_FILENAME); BOOST_CHECK_EQUAL( - I.get<std::string>("section2", "key3"), - "value with even more spaces" - ); - BOOST_CHECK_EQUAL( - I.get<std::string>("section1", "key1"), - "value1" - ); - BOOST_CHECK_EQUAL( - I.get<std::string>("section3", "key4"), - "\"with quotes\"" - ); + I.get<std::string>("section2", "key3"), "value with even more spaces"); + BOOST_CHECK_EQUAL(I.get<std::string>("section1", "key1"), "value1"); + BOOST_CHECK_EQUAL(I.get<std::string>("section3", "key4"), "\"with quotes\""); cleanup_config_parsers(); } |