aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/fp_compare_delta_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/fp_compare_delta_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/fp_compare_delta_test.cpp')
-rw-r--r--host/tests/fp_compare_delta_test.cpp134
1 files changed, 76 insertions, 58 deletions
diff --git a/host/tests/fp_compare_delta_test.cpp b/host/tests/fp_compare_delta_test.cpp
index 5023d660a..ae1f14281 100644
--- a/host/tests/fp_compare_delta_test.cpp
+++ b/host/tests/fp_compare_delta_test.cpp
@@ -10,20 +10,21 @@
using namespace uhd::math::fp_compare;
-BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors) {
+BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors)
+{
// Test default constructor
fp_compare_delta<float> alpha = fp_compare_delta<float>(7457392.0);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._delta, beta._delta);
// Test constructor with specified delta
- fp_compare_delta<float> foxtrot = fp_compare_delta<float>(alpha._value,
- uhd::math::SINGLE_PRECISION_DELTA);
- fp_compare_delta<float> gamma = fp_compare_delta<float>(alpha._value,
- 2 * uhd::math::SINGLE_PRECISION_DELTA);
+ fp_compare_delta<float> foxtrot =
+ fp_compare_delta<float>(alpha._value, uhd::math::SINGLE_PRECISION_DELTA);
+ fp_compare_delta<float> gamma =
+ fp_compare_delta<float>(alpha._value, 2 * uhd::math::SINGLE_PRECISION_DELTA);
BOOST_CHECK_EQUAL(alpha._delta, foxtrot._delta);
- BOOST_CHECK(not (alpha._delta == gamma._delta));
+ BOOST_CHECK(not(alpha._delta == gamma._delta));
// Test copy-constructor
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha);
@@ -36,19 +37,20 @@ BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors) {
BOOST_CHECK_EQUAL(alpha._delta, delta._delta);
}
-BOOST_AUTO_TEST_CASE(double_compare_constructors) {
+BOOST_AUTO_TEST_CASE(double_compare_constructors)
+{
// Test default constructor
fp_compare_delta<double> alpha = fp_compare_delta<double>(45739210286.0101);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._delta, beta._delta);
// Test constructor with specified delta
- fp_compare_delta<double> foxtrot = fp_compare_delta<double>(alpha._value,
- uhd::math::DOUBLE_PRECISION_DELTA);
+ fp_compare_delta<double> foxtrot =
+ fp_compare_delta<double>(alpha._value, uhd::math::DOUBLE_PRECISION_DELTA);
fp_compare_delta<double> gamma = fp_compare_delta<double>(alpha._value, 2.0e-6);
BOOST_CHECK_EQUAL(alpha._delta, foxtrot._delta);
- BOOST_CHECK(not (alpha._delta == gamma._delta));
+ BOOST_CHECK(not(alpha._delta == gamma._delta));
// Test copy-constructor
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha);
@@ -61,56 +63,61 @@ BOOST_AUTO_TEST_CASE(double_compare_constructors) {
BOOST_CHECK_EQUAL(alpha._delta, delta._delta);
}
-BOOST_AUTO_TEST_CASE(float_equality_operators) {
+BOOST_AUTO_TEST_CASE(float_equality_operators)
+{
// Test basic equality operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(1.0);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == float(alpha._value));
// Test equality edge case at difference = delta
- fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value
- + uhd::math::SINGLE_PRECISION_DELTA);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_DELTA)));
+ fp_compare_delta<float> charlie =
+ fp_compare_delta<float>(alpha._value + uhd::math::SINGLE_PRECISION_DELTA);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_DELTA)));
}
-BOOST_AUTO_TEST_CASE(double_equality_operators) {
+BOOST_AUTO_TEST_CASE(double_equality_operators)
+{
// Test basic equality operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(1.0);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == double(beta._value));
// Test equality edge case at delta = delta
- fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value
- + uhd::math::DOUBLE_PRECISION_DELTA);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == double(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA)));
+ fp_compare_delta<double> charlie =
+ fp_compare_delta<double>(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == double(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA)));
}
-BOOST_AUTO_TEST_CASE(float_inequality_operators) {
+BOOST_AUTO_TEST_CASE(float_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(127.0f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3f);
BOOST_CHECK(alpha != beta);
BOOST_CHECK(alpha != float(alpha._value + 1.19e-3));
}
-BOOST_AUTO_TEST_CASE(double_inequality_operators) {
+BOOST_AUTO_TEST_CASE(double_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(1.0);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 1.19e-5);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 1.19e-5);
BOOST_CHECK(alpha != beta);
BOOST_CHECK(alpha != double(alpha._value + 1.19e-5));
}
-BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthan_operators)
+{
// Test less-than operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(274192.7f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2f);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(float(alpha._value - 0.2) < alpha);
@@ -118,14 +125,15 @@ BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
// Confirm false less-than case
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2f);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < float(alpha._value - 1.2f)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < float(alpha._value - 1.2f)));
}
-BOOST_AUTO_TEST_CASE(double_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthan_operators)
+{
// Test less-than operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(274192856.762312);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value - 0.0002);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value - 0.0002);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(double(alpha._value - 0.0002) < alpha);
@@ -133,14 +141,15 @@ BOOST_AUTO_TEST_CASE(double_lessthan_operators) {
// Confirm false less-than case
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value - 1.0012);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < double(alpha._value - 1.0012)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < double(alpha._value - 1.0012)));
}
-BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_delta<float> alpha = fp_compare_delta<float>(827.3f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= float(alpha._value));
@@ -152,10 +161,11 @@ BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
BOOST_CHECK(float(alpha._value - 1.2) <= alpha);
}
-BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_delta<double> alpha = fp_compare_delta<double>(837652123.383764);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= double(alpha._value));
@@ -167,10 +177,11 @@ BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) {
BOOST_CHECK(double(alpha._value - 0.0012) <= alpha);
}
-BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_delta<float> alpha = fp_compare_delta<float>(98325.4f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15f);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(float(alpha._value + 0.15) > alpha);
@@ -178,14 +189,15 @@ BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
// Test false greater-than case
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 1.2f);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > float(alpha._value + 1.2)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > float(alpha._value + 1.2)));
}
-BOOST_AUTO_TEST_CASE(double_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_delta<double> alpha = fp_compare_delta<double>(643907213.428475);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 0.0002);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 0.0002);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(double(alpha._value + 0.0002) > alpha);
@@ -193,14 +205,15 @@ BOOST_AUTO_TEST_CASE(double_greaterthan_operators) {
// Test false greater-than case
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value + 0.0012);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > double(alpha._value + 0.0012)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > double(alpha._value + 0.0012)));
}
-BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_delta<float> alpha = fp_compare_delta<float>(7834.89f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= float(alpha._value));
@@ -212,10 +225,11 @@ BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
BOOST_CHECK(float(alpha._value + 4.8) >= alpha);
}
-BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_delta<double> alpha = fp_compare_delta<double>(737623834.89843);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= double(alpha._value));
@@ -227,16 +241,20 @@ BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) {
BOOST_CHECK(double(alpha._value + 3.0008) >= alpha);
}
-BOOST_AUTO_TEST_CASE(fp_compare_large_delta) {
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) == 61440000.000000000000);
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) <= 61440000.000000000000);
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) >= 61440000.000000000000);
+BOOST_AUTO_TEST_CASE(fp_compare_large_delta)
+{
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) == 61440000.000000000000);
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) <= 61440000.000000000000);
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) >= 61440000.000000000000);
BOOST_CHECK(fp_compare_delta<double>(1.0, 10.0) == 2.0);
}
-BOOST_AUTO_TEST_CASE(frequency_compare_function) {
-
+BOOST_AUTO_TEST_CASE(frequency_compare_function)
+{
BOOST_CHECK(uhd::math::frequencies_are_equal(6817333232.0, 6817333232.0));
BOOST_CHECK(!uhd::math::frequencies_are_equal(6817333233.0, 6817333232.0));
BOOST_CHECK(uhd::math::frequencies_are_equal(6817333232.1, 6817333232.1));