summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/math/qa_fxpt_nco.cc')
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt_nco.cc39
1 files changed, 13 insertions, 26 deletions
diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
index 16ea120381..cd05747630 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,10 +24,9 @@
#include <config.h>
#endif
-#include <qa_fxpt_nco.h>
#include <gnuradio/fxpt_nco.h>
#include <gnuradio/nco.h>
-#include <cppunit/TestAssert.h>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#include <stdio.h>
#include <unistd.h>
@@ -45,9 +44,8 @@ static double max_d(double a, double b)
return fabs(a) > fabs(b) ? a : b;
}
-void
-qa_fxpt_nco::t0()
-{
+
+BOOST_AUTO_TEST_CASE(t0) {
gr::nco<float,float> ref_nco;
gr::fxpt_nco new_nco;
double max_error = 0, max_phase_error = 0;
@@ -55,35 +53,33 @@ qa_fxpt_nco::t0()
ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE);
for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
float ref_sin = ref_nco.sin();
float new_sin = new_nco.sin();
//printf ("i = %6d\n", i);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_sin, new_sin, SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_sin - new_sin) <= SIN_COS_TOLERANCE);
max_error = max_d(max_error, ref_sin-new_sin);
float ref_cos = ref_nco.cos();
float new_cos = new_nco.cos();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_cos, new_cos, SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_cos - new_cos) <= SIN_COS_TOLERANCE);
max_error = max_d(max_error, ref_cos-new_cos);
ref_nco.step();
new_nco.step();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_nco.get_phase() - new_nco.get_phase()) <= SIN_COS_TOLERANCE);
max_phase_error = max_d(max_phase_error, ref_nco.get_phase()-new_nco.get_phase());
}
// printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error);
}
-void
-qa_fxpt_nco::t1()
-{
+BOOST_AUTO_TEST_CASE(t1) {
gr::nco<float,float> ref_nco;
gr::fxpt_nco new_nco;
gr_complex* ref_block = new gr_complex[SIN_COS_BLOCK_SIZE];
@@ -93,30 +89,21 @@ qa_fxpt_nco::t1()
ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE);
ref_nco.sincos((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE);
new_nco.sincos((gr_complex*)new_block, SIN_COS_BLOCK_SIZE);
for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) {
- CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_block[i].real() - new_block[i].real()) <= SIN_COS_TOLERANCE);
max_error = max_d (max_error, ref_block[i].real()-new_block[i].real());
- CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_block[i].imag() - new_block[i].imag()) <= SIN_COS_TOLERANCE);
max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag());
}
- CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(ref_nco.get_phase() - new_nco.get_phase()) <= SIN_COS_TOLERANCE);
// printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error);
delete[] ref_block;
delete[] new_block;
}
-void
-qa_fxpt_nco::t2()
-{
-}
-
-void
-qa_fxpt_nco::t3()
-{
-}