summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math/qa_fxpt.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/math/qa_fxpt.cc')
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt.cc57
1 files changed, 24 insertions, 33 deletions
diff --git a/gnuradio-runtime/lib/math/qa_fxpt.cc b/gnuradio-runtime/lib/math/qa_fxpt.cc
index d3aadf85b1..f369cd356a 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt.cc
@@ -24,9 +24,8 @@
#include <config.h>
#endif
-#include <qa_fxpt.h>
#include <gnuradio/fxpt.h>
-#include <cppunit/TestAssert.h>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#include <stdio.h>
#include <unistd.h>
@@ -34,12 +33,10 @@
static const float SIN_COS_TOLERANCE = 1e-5;
-void
-qa_fxpt::t0()
-{
- CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/2, gr::fxpt::fixed_to_float(0x40000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, gr::fxpt::fixed_to_float(0x00000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-M_PI, gr::fxpt::fixed_to_float(0x80000000), SIN_COS_TOLERANCE);
+BOOST_AUTO_TEST_CASE(t0) {
+ BOOST_CHECK(std::abs(M_PI/2 - gr::fxpt::fixed_to_float(0x40000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(0.0 - gr::fxpt::fixed_to_float(0x00000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(-M_PI - gr::fxpt::fixed_to_float(0x80000000)) <= SIN_COS_TOLERANCE);
if(0) {
/*
@@ -51,52 +48,46 @@ qa_fxpt::t0()
* sometimes the answer is off by a few bits at the bottom.
* Hence, the disabled check.
*/
- CPPUNIT_ASSERT_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2));
- CPPUNIT_ASSERT_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0));
- CPPUNIT_ASSERT_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI));
+ BOOST_CHECK_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2));
+ BOOST_CHECK_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0));
+ BOOST_CHECK_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI));
}
}
-void
-qa_fxpt::t1()
-{
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x00000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, gr::fxpt::sin(0x20000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, gr::fxpt::sin(0x40000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, gr::fxpt::sin(0x60000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x7fffffff), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x80000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x80000001), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-1, gr::fxpt::sin(-0x40000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.707106781, gr::fxpt::sin(-0x20000000), SIN_COS_TOLERANCE);
+BOOST_AUTO_TEST_CASE(t1) {
+ BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x00000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 0.707106781 - gr::fxpt::sin(0x20000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 1 - gr::fxpt::sin(0x40000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 0.707106781 - gr::fxpt::sin(0x60000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x7fffffff)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x80000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x80000001)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(-1 - gr::fxpt::sin(-0x40000000)) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(-0.707106781 - gr::fxpt::sin(-0x20000000)) <= SIN_COS_TOLERANCE);
for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
float expected = sin(p);
float actual = gr::fxpt::sin(gr::fxpt::float_to_fixed (p));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE);
}
}
-void
-qa_fxpt::t2()
-{
+BOOST_AUTO_TEST_CASE(t2) {
for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
float expected = cos(p);
float actual = gr::fxpt::cos(gr::fxpt::float_to_fixed(p));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE);
}
}
-void
-qa_fxpt::t3()
-{
+BOOST_AUTO_TEST_CASE(t3) {
for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
float expected_sin = sin(p);
float expected_cos = cos(p);
float actual_sin;
float actual_cos;
gr::fxpt::sincos(gr::fxpt::float_to_fixed (p), &actual_sin, &actual_cos);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_sin, actual_sin, SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_cos, actual_cos, SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(expected_sin - actual_sin) <= SIN_COS_TOLERANCE);
+ BOOST_CHECK(std::abs(expected_cos - actual_cos) <= SIN_COS_TOLERANCE);
}
}