summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-digital/lib/CMakeLists.txt29
-rw-r--r--gr-digital/lib/qa_digital.cc41
-rw-r--r--gr-digital/lib/qa_digital.h38
-rw-r--r--gr-digital/lib/qa_header_buffer.cc249
-rw-r--r--gr-digital/lib/qa_header_buffer.h59
-rw-r--r--gr-digital/lib/qa_header_format.cc83
-rw-r--r--gr-digital/lib/qa_header_format.h47
7 files changed, 166 insertions, 380 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index 1fcae4713a..b6754d1ce9 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -211,27 +211,18 @@ if(ENABLE_TESTING)
include_directories(
${GR_DIGITAL_INCLUDE_DIRS}
- ${CPPUNIT_INCLUDE_DIRS})
- link_directories(${CPPUNIT_LIBRARY_DIRS})
+ ${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ )
list(APPEND test_gr_digital_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_digital.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_digital.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_header_format.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_header_buffer.cc
- )
-
- add_executable(test-gr-digital ${test_gr_digital_sources})
-
- list(APPEND GR_TEST_TARGET_DEPS test-gr-digital gnuradio-digital)
-
- target_link_libraries(
- test-gr-digital
- gnuradio-runtime
- gnuradio-digital
- ${Boost_LIBRARIES}
- ${CPPUNIT_LIBRARIES}
+ qa_header_format.cc
+ qa_header_buffer.cc
)
+ list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital)
- GR_ADD_TEST(test_gr_digital test-gr-digital)
+ foreach(qa_file ${test_gr_digital_sources})
+ GR_ADD_CPP_TEST("digital_${qa_file}"
+ ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file}
+ )
+ endforeach(qa_file)
endif(ENABLE_TESTING)
diff --git a/gr-digital/lib/qa_digital.cc b/gr-digital/lib/qa_digital.cc
deleted file mode 100644
index 2888d2129d..0000000000
--- a/gr-digital/lib/qa_digital.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * This class gathers together all the test cases for the gr-digital
- * directory into a single test suite. As you create new test cases,
- * add them here.
- */
-
-#include "qa_digital.h"
-#include "qa_header_format.h"
-#include "qa_header_buffer.h"
-
-CppUnit::TestSuite *
-qa_digital::suite()
-{
- CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-digital");
-
- s->addTest(qa_header_format::suite());
- s->addTest(qa_header_buffer::suite());
-
- return s;
-}
diff --git a/gr-digital/lib/qa_digital.h b/gr-digital/lib/qa_digital.h
deleted file mode 100644
index c5f3592960..0000000000
--- a/gr-digital/lib/qa_digital.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _QA_GR_DIGITAL_H_
-#define _QA_GR_DIGITAL_H_
-
-#include <gnuradio/attributes.h>
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the gr-digital directory
-
-class __GR_ATTR_EXPORT qa_digital
-{
- public:
- //! return suite of tests for all of gr-digital directory
- static CppUnit::TestSuite *suite();
-};
-
-#endif /* _QA_GR_DIGITAL_H_ */
diff --git a/gr-digital/lib/qa_header_buffer.cc b/gr-digital/lib/qa_header_buffer.cc
index 321e90138c..5f7702cd0d 100644
--- a/gr-digital/lib/qa_header_buffer.cc
+++ b/gr-digital/lib/qa_header_buffer.cc
@@ -24,17 +24,13 @@
#include <config.h>
#endif
-#include <volk/volk.h>
#include <gnuradio/attributes.h>
-
-#include <stdio.h>
-#include <cppunit/TestAssert.h>
-
-#include "qa_header_buffer.h"
#include <gnuradio/digital/header_buffer.h>
+#include <volk/volk.h>
+#include <boost/test/unit_test.hpp>
+#include <stdio.h>
-void
-qa_header_buffer::test_add8()
+BOOST_AUTO_TEST_CASE(test_add8)
{
size_t len = sizeof(uint8_t);
uint8_t *buf = (uint8_t*)volk_malloc(len, volk_get_alignment());
@@ -42,17 +38,16 @@ qa_header_buffer::test_add8()
gr::digital::header_buffer header(buf);
header.add_field8(0xAF);
- CPPUNIT_ASSERT_EQUAL(len, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[0]);
+ BOOST_REQUIRE_EQUAL(len, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[0]);
header.clear();
- CPPUNIT_ASSERT_EQUAL((size_t)0, header.length());
+ BOOST_REQUIRE_EQUAL((size_t)0, header.length());
volk_free(buf);
}
-void
-qa_header_buffer::test_add16()
+BOOST_AUTO_TEST_CASE(test_add16)
{
size_t len = sizeof(uint16_t);
uint8_t *buf = (uint8_t*)volk_malloc(len, volk_get_alignment());
@@ -63,38 +58,37 @@ qa_header_buffer::test_add16()
header.add_field16(data);
// Test standard add of a uint16
- CPPUNIT_ASSERT_EQUAL(len, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[1]);
+ BOOST_REQUIRE_EQUAL(len, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[1]);
// Clear; test to make sure it's clear
header.clear();
- CPPUNIT_ASSERT_EQUAL((size_t)0, header.length());
+ BOOST_REQUIRE_EQUAL((size_t)0, header.length());
// Test adding some subset of bits (must be a byte boundary)
header.add_field16(data, 8);
- CPPUNIT_ASSERT_EQUAL((size_t)1, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((size_t)1, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[0]);
header.clear();
// Test adding and byte swapping
header.add_field16(data, 16, true);
- CPPUNIT_ASSERT_EQUAL((size_t)2, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((size_t)2, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[1]);
header.clear();
// Test adding some subset of bits and byte swapping
header.add_field16(data, 8, true);
- CPPUNIT_ASSERT_EQUAL((size_t)1, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((size_t)1, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[0]);
header.clear();
volk_free(buf);
}
-void
-qa_header_buffer::test_add32()
+BOOST_AUTO_TEST_CASE(test_add32)
{
size_t len = sizeof(uint32_t);
uint8_t *buf = (uint8_t*)volk_malloc(len, volk_get_alignment());
@@ -105,44 +99,43 @@ qa_header_buffer::test_add32()
header.add_field32(data);
// Test standard add of a uint32
- CPPUNIT_ASSERT_EQUAL(len, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[3]);
+ BOOST_REQUIRE_EQUAL(len, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[3]);
// Clear; test to make sure it's clear
header.clear();
- CPPUNIT_ASSERT_EQUAL((size_t)0, header.length());
+ BOOST_REQUIRE_EQUAL((size_t)0, header.length());
// Test adding some subset of bits (must be a byte boundary)
header.add_field32(data, 8);
- CPPUNIT_ASSERT_EQUAL((size_t)1, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((size_t)1, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[0]);
header.clear();
// Test adding and byte swapping
header.add_field32(data, 32, true);
- CPPUNIT_ASSERT_EQUAL((size_t)4, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((size_t)4, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[3]);
header.clear();
// Test adding some subset of bits and byte swapping
header.add_field32(data, 24, true);
- CPPUNIT_ASSERT_EQUAL((size_t)3, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((size_t)3, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[2]);
header.clear();
volk_free(buf);
}
-void
-qa_header_buffer::test_add64()
+BOOST_AUTO_TEST_CASE(test_add64)
{
size_t len = sizeof(uint64_t);
uint8_t *buf = (uint8_t*)volk_malloc(len, volk_get_alignment());
@@ -153,59 +146,58 @@ qa_header_buffer::test_add64()
header.add_field64(data);
// Test standard add of a uint64
- CPPUNIT_ASSERT_EQUAL(len, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[3]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x32, header.header()[4]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x10, header.header()[5]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[6]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x67, header.header()[7]);
+ BOOST_REQUIRE_EQUAL(len, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x32, header.header()[4]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x10, header.header()[5]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[6]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x67, header.header()[7]);
// Clear; test to make sure it's clear
header.clear();
- CPPUNIT_ASSERT_EQUAL((size_t)0, header.length());
+ BOOST_REQUIRE_EQUAL((size_t)0, header.length());
// Test adding some subset of bits (must be a byte boundary)
header.add_field64(data, 48);
- CPPUNIT_ASSERT_EQUAL((size_t)6, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x32, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x10, header.header()[3]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[4]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x67, header.header()[5]);
+ BOOST_REQUIRE_EQUAL((size_t)6, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x32, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x10, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[4]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x67, header.header()[5]);
header.clear();
// Test adding and byte swapping
header.add_field64(data, 64, true);
- CPPUNIT_ASSERT_EQUAL((size_t)8, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x67, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x10, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x32, header.header()[3]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[4]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[5]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x5C, header.header()[6]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAF, header.header()[7]);
+ BOOST_REQUIRE_EQUAL((size_t)8, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x67, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x10, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x32, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[4]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[5]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x5C, header.header()[6]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAF, header.header()[7]);
header.clear();
// Test adding some subset of bits and byte swapping
header.add_field64(data, 40, true);
- CPPUNIT_ASSERT_EQUAL((size_t)5, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x67, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x10, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x32, header.header()[3]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[4]);
+ BOOST_REQUIRE_EQUAL((size_t)5, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x67, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x10, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x32, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[4]);
header.clear();
volk_free(buf);
}
-void
-qa_header_buffer::test_add_many()
+BOOST_AUTO_TEST_CASE(test_add_many)
{
size_t len = (32+64+8+16+32)/8;
uint8_t *buf = (uint8_t*)volk_malloc(len, volk_get_alignment());
@@ -217,30 +209,29 @@ qa_header_buffer::test_add_many()
header.add_field16(0x5432);
header.add_field32(0x10012345);
- CPPUNIT_ASSERT_EQUAL(len, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x01, header.header()[0]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x23, header.header()[1]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[2]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x67, header.header()[3]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x89, header.header()[4]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xAB, header.header()[5]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xCD, header.header()[6]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xEF, header.header()[7]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xFE, header.header()[8]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xDC, header.header()[9]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0xBA, header.header()[10]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x98, header.header()[11]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x76, header.header()[12]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x54, header.header()[13]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x32, header.header()[14]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x10, header.header()[15]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x01, header.header()[16]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x23, header.header()[17]);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x45, header.header()[18]);
+ BOOST_REQUIRE_EQUAL(len, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x01, header.header()[0]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x23, header.header()[1]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[2]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x67, header.header()[3]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x89, header.header()[4]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xAB, header.header()[5]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xCD, header.header()[6]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xEF, header.header()[7]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xFE, header.header()[8]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xDC, header.header()[9]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0xBA, header.header()[10]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x98, header.header()[11]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x76, header.header()[12]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x54, header.header()[13]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x32, header.header()[14]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x10, header.header()[15]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x01, header.header()[16]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x23, header.header()[17]);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x45, header.header()[18]);
}
-void
-qa_header_buffer::test_extract8()
+BOOST_AUTO_TEST_CASE(test_extract8)
{
gr::digital::header_buffer header;
@@ -257,14 +248,13 @@ qa_header_buffer::test_extract8()
uint8_t x1 = header.extract_field8(12, 8);
uint8_t x2 = header.extract_field8(12, 4);
- CPPUNIT_ASSERT_EQUAL((size_t)64, header.length());
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x80, x0);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x4A, x1);
- CPPUNIT_ASSERT_EQUAL((uint8_t)0x04, x2);
+ BOOST_REQUIRE_EQUAL((size_t)64, header.length());
+ BOOST_REQUIRE_EQUAL((uint8_t)0x80, x0);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x4A, x1);
+ BOOST_REQUIRE_EQUAL((uint8_t)0x04, x2);
}
-void
-qa_header_buffer::test_extract16()
+BOOST_AUTO_TEST_CASE(test_extract16)
{
gr::digital::header_buffer header;
@@ -281,14 +271,13 @@ qa_header_buffer::test_extract16()
uint16_t x1 = header.extract_field16(12, 16);
uint16_t x2 = header.extract_field16(12, 12);
- CPPUNIT_ASSERT_EQUAL((size_t)64, header.length());
- CPPUNIT_ASSERT_EQUAL((uint16_t)0x80C4, x0);
- CPPUNIT_ASSERT_EQUAL((uint16_t)0x4A2E, x1);
- CPPUNIT_ASSERT_EQUAL((uint16_t)0x04A2, x2);
+ BOOST_REQUIRE_EQUAL((size_t)64, header.length());
+ BOOST_REQUIRE_EQUAL((uint16_t)0x80C4, x0);
+ BOOST_REQUIRE_EQUAL((uint16_t)0x4A2E, x1);
+ BOOST_REQUIRE_EQUAL((uint16_t)0x04A2, x2);
}
-void
-qa_header_buffer::test_extract32()
+BOOST_AUTO_TEST_CASE(test_extract32)
{
gr::digital::header_buffer header;
@@ -305,14 +294,13 @@ qa_header_buffer::test_extract32()
uint32_t x1 = header.extract_field32(12, 32);
uint32_t x2 = header.extract_field32(12, 24);
- CPPUNIT_ASSERT_EQUAL((size_t)64, header.length());
- CPPUNIT_ASSERT_EQUAL((uint32_t)0x80C4A2E6, x0);
- CPPUNIT_ASSERT_EQUAL((uint32_t)0x4A2E680C, x1);
- CPPUNIT_ASSERT_EQUAL((uint32_t)0x004A2E68, x2);
+ BOOST_REQUIRE_EQUAL((size_t)64, header.length());
+ BOOST_REQUIRE_EQUAL((uint32_t)0x80C4A2E6, x0);
+ BOOST_REQUIRE_EQUAL((uint32_t)0x4A2E680C, x1);
+ BOOST_REQUIRE_EQUAL((uint32_t)0x004A2E68, x2);
}
-void
-qa_header_buffer::test_extract64()
+BOOST_AUTO_TEST_CASE(test_extract64)
{
gr::digital::header_buffer header;
@@ -329,14 +317,13 @@ qa_header_buffer::test_extract64()
uint64_t x1 = header.extract_field64(0, 32);
uint64_t x2 = header.extract_field64(0, 44);
- CPPUNIT_ASSERT_EQUAL((size_t)64, header.length());
- CPPUNIT_ASSERT_EQUAL((uint64_t)0x80C4A2E680C4A2E6, x0);
- CPPUNIT_ASSERT_EQUAL((uint64_t)0x0000000080C4A2E6, x1);
- CPPUNIT_ASSERT_EQUAL((uint64_t)0x0000080C4A2E680C, x2);
+ BOOST_REQUIRE_EQUAL((size_t)64, header.length());
+ BOOST_REQUIRE_EQUAL((uint64_t)0x80C4A2E680C4A2E6, x0);
+ BOOST_REQUIRE_EQUAL((uint64_t)0x0000000080C4A2E6, x1);
+ BOOST_REQUIRE_EQUAL((uint64_t)0x0000080C4A2E680C, x2);
}
-void
-qa_header_buffer::test_extract_many()
+BOOST_AUTO_TEST_CASE(test_extract_many)
{
gr::digital::header_buffer header;
@@ -355,10 +342,10 @@ qa_header_buffer::test_extract_many()
uint16_t x3 = header.extract_field16(1, 12);
uint8_t x4 = header.extract_field8 (7, 5);
- CPPUNIT_ASSERT_EQUAL((size_t)64, header.length());
- CPPUNIT_ASSERT_EQUAL((uint64_t)0x80C4A2E680C4A2E6, x0);
- CPPUNIT_ASSERT_EQUAL((uint16_t)0x0680, x1);
- CPPUNIT_ASSERT_EQUAL((uint32_t)0x0018945C, x2);
- CPPUNIT_ASSERT_EQUAL((uint16_t)0x0018, x3);
- CPPUNIT_ASSERT_EQUAL((uint8_t) 0x0C, x4);
+ BOOST_REQUIRE_EQUAL((size_t)64, header.length());
+ BOOST_REQUIRE_EQUAL((uint64_t)0x80C4A2E680C4A2E6, x0);
+ BOOST_REQUIRE_EQUAL((uint16_t)0x0680, x1);
+ BOOST_REQUIRE_EQUAL((uint32_t)0x0018945C, x2);
+ BOOST_REQUIRE_EQUAL((uint16_t)0x0018, x3);
+ BOOST_REQUIRE_EQUAL((uint8_t) 0x0C, x4);
}
diff --git a/gr-digital/lib/qa_header_buffer.h b/gr-digital/lib/qa_header_buffer.h
deleted file mode 100644
index 48ab086293..0000000000
--- a/gr-digital/lib/qa_header_buffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2016 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _QA_DIGITAL_HEADER_BUFFER_H_
-#define _QA_DIGITAL_HEADER_BUFFER_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_header_buffer : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_header_buffer);
- CPPUNIT_TEST(test_add8);
- CPPUNIT_TEST(test_add16);
- CPPUNIT_TEST(test_add32);
- CPPUNIT_TEST(test_add64);
- CPPUNIT_TEST(test_add_many);
-
- CPPUNIT_TEST(test_extract8);
- CPPUNIT_TEST(test_extract16);
- CPPUNIT_TEST(test_extract32);
- CPPUNIT_TEST(test_extract64);
- CPPUNIT_TEST(test_extract_many);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- void test_add8();
- void test_add16();
- void test_add32();
- void test_add64();
- void test_add_many();
-
- void test_extract8();
- void test_extract16();
- void test_extract32();
- void test_extract64();
- void test_extract_many();
-};
-
-#endif /* _QA_DIGITAL_HEADER_BUFFER_H_ */
diff --git a/gr-digital/lib/qa_header_format.cc b/gr-digital/lib/qa_header_format.cc
index b06a2dd5c0..c91e8f93bb 100644
--- a/gr-digital/lib/qa_header_format.cc
+++ b/gr-digital/lib/qa_header_format.cc
@@ -25,20 +25,16 @@
#endif
#include <gnuradio/attributes.h>
-
-#include <stdio.h>
-#include <cmath>
-#include <volk/volk.h>
-#include <gnuradio/expj.h>
-#include <cppunit/TestAssert.h>
-
-#include "qa_header_format.h"
#include <gnuradio/digital/header_format_counter.h>
#include <gnuradio/digital/header_format_default.h>
#include <gnuradio/blocks/unpack_k_bits.h>
+#include <gnuradio/expj.h>
+#include <volk/volk.h>
+#include <boost/test/unit_test.hpp>
+#include <stdio.h>
+#include <cmath>
-void
-qa_header_format::test_default_format()
+BOOST_AUTO_TEST_CASE(test_default_format)
{
static const int N = 4800;
int upper8 = (N >> 8) & 0xFF;
@@ -61,32 +57,31 @@ qa_header_format::test_default_format()
bool ret = hdr_format->format(N, data, output, info);
size_t length = pmt::length(output);
- CPPUNIT_ASSERT(ret);
- CPPUNIT_ASSERT_EQUAL(length, hdr_format->header_nbytes());
- CPPUNIT_ASSERT_EQUAL(8*length, hdr_format->header_nbits());
+ BOOST_REQUIRE(ret);
+ BOOST_REQUIRE_EQUAL(length, hdr_format->header_nbytes());
+ BOOST_REQUIRE_EQUAL(8*length, hdr_format->header_nbits());
// Test access code formatted correctly
unsigned char h0 = pmt::u8vector_ref(output, 0);
unsigned char h1 = pmt::u8vector_ref(output, 1);
- CPPUNIT_ASSERT_EQUAL(0xAA, (int)h0);
- CPPUNIT_ASSERT_EQUAL(0xAA, (int)h1);
+ BOOST_REQUIRE_EQUAL(0xAA, (int)h0);
+ BOOST_REQUIRE_EQUAL(0xAA, (int)h1);
// Test upper and lower portion of length field, repeated twice
unsigned char h2 = pmt::u8vector_ref(output, 2);
unsigned char h3 = pmt::u8vector_ref(output, 3);
unsigned char h4 = pmt::u8vector_ref(output, 4);
unsigned char h5 = pmt::u8vector_ref(output, 5);
- CPPUNIT_ASSERT_EQUAL(upper8, (int)h2);
- CPPUNIT_ASSERT_EQUAL(lower8, (int)h3);
- CPPUNIT_ASSERT_EQUAL(upper8, (int)h4);
- CPPUNIT_ASSERT_EQUAL(lower8, (int)h5);
+ BOOST_REQUIRE_EQUAL(upper8, (int)h2);
+ BOOST_REQUIRE_EQUAL(lower8, (int)h3);
+ BOOST_REQUIRE_EQUAL(upper8, (int)h4);
+ BOOST_REQUIRE_EQUAL(lower8, (int)h5);
volk_free(data);
}
-void
-qa_header_format::test_default_parse()
+BOOST_AUTO_TEST_CASE(test_default_parse)
{
static const int nbytes = 106;
static const int nbits = 8*nbytes;
@@ -121,8 +116,8 @@ qa_header_format::test_default_parse()
std::vector<pmt::pmt_t> info;
bool ret = hdr_format->parse(nbits, bits, info, count);
- CPPUNIT_ASSERT(ret);
- CPPUNIT_ASSERT_EQUAL((size_t)1, info.size());
+ BOOST_REQUIRE(ret);
+ BOOST_REQUIRE_EQUAL((size_t)1, info.size());
pmt::pmt_t dict = info[0];
int payload_bits = pmt::to_long(pmt::dict_ref(dict, pmt::intern("payload symbols"),
@@ -130,14 +125,13 @@ qa_header_format::test_default_parse()
int hdr_bits = (int)hdr_format->header_nbits();
int expected_bits = nbits - hdr_bits;
- CPPUNIT_ASSERT_EQUAL(expected_bits, payload_bits);
+ BOOST_REQUIRE_EQUAL(expected_bits, payload_bits);
volk_free(bytes);
volk_free(bits);
}
-void
-qa_header_format::test_counter_format()
+BOOST_AUTO_TEST_CASE(test_counter_format)
{
static const int N = 4800;
int upper8 = (N >> 8) & 0xFF;
@@ -161,49 +155,48 @@ qa_header_format::test_counter_format()
bool ret = hdr_format->format(N, data, output, info);
size_t length = pmt::length(output);
- CPPUNIT_ASSERT(ret);
- CPPUNIT_ASSERT_EQUAL(length, hdr_format->header_nbytes());
- CPPUNIT_ASSERT_EQUAL(8*length, hdr_format->header_nbits());
+ BOOST_REQUIRE(ret);
+ BOOST_REQUIRE_EQUAL(length, hdr_format->header_nbytes());
+ BOOST_REQUIRE_EQUAL(8*length, hdr_format->header_nbits());
// Test access code formatted correctly
unsigned char h0 = pmt::u8vector_ref(output, 0);
unsigned char h1 = pmt::u8vector_ref(output, 1);
- CPPUNIT_ASSERT_EQUAL(0xAA, (int)h0);
- CPPUNIT_ASSERT_EQUAL(0xAA, (int)h1);
+ BOOST_REQUIRE_EQUAL(0xAA, (int)h0);
+ BOOST_REQUIRE_EQUAL(0xAA, (int)h1);
// Test upper and lower portion of length field, repeated twice
unsigned char h2 = pmt::u8vector_ref(output, 2);
unsigned char h3 = pmt::u8vector_ref(output, 3);
unsigned char h4 = pmt::u8vector_ref(output, 4);
unsigned char h5 = pmt::u8vector_ref(output, 5);
- CPPUNIT_ASSERT_EQUAL(upper8, (int)h2);
- CPPUNIT_ASSERT_EQUAL(lower8, (int)h3);
- CPPUNIT_ASSERT_EQUAL(upper8, (int)h4);
- CPPUNIT_ASSERT_EQUAL(lower8, (int)h5);
+ BOOST_REQUIRE_EQUAL(upper8, (int)h2);
+ BOOST_REQUIRE_EQUAL(lower8, (int)h3);
+ BOOST_REQUIRE_EQUAL(upper8, (int)h4);
+ BOOST_REQUIRE_EQUAL(lower8, (int)h5);
uint16_t h6 = (uint16_t)pmt::u8vector_ref(output, 6);
uint16_t h7 = (uint16_t)pmt::u8vector_ref(output, 7);
uint16_t bps = ((h6 << 8) & 0xFF00) | (h7 & 0x00FF);
- CPPUNIT_ASSERT_EQUAL(expected_bps, bps);
+ BOOST_REQUIRE_EQUAL(expected_bps, bps);
uint16_t h8 = pmt::u8vector_ref(output, 8);
uint16_t h9 = pmt::u8vector_ref(output, 9);
uint16_t counter = ((h8 << 8) & 0xFF00) | (h9 & 0x00FF);
- CPPUNIT_ASSERT_EQUAL((uint16_t)0, counter);
+ BOOST_REQUIRE_EQUAL((uint16_t)0, counter);
// Run another format to increment the counter to 1 and test.
ret = hdr_format->format(N, data, output, info);
h8 = pmt::u8vector_ref(output, 8);
h9 = pmt::u8vector_ref(output, 9);
counter = ((h8 << 8) & 0xFF00) | (h9 & 0x00FF);
- CPPUNIT_ASSERT_EQUAL((uint16_t)1, counter);
+ BOOST_REQUIRE_EQUAL((uint16_t)1, counter);
volk_free(data);
}
-void
-qa_header_format::test_counter_parse()
+BOOST_AUTO_TEST_CASE(test_counter_parse)
{
static const int nbytes = 110;
static const int nbits = 8*nbytes;
@@ -243,8 +236,8 @@ qa_header_format::test_counter_parse()
std::vector<pmt::pmt_t> info;
bool ret = hdr_format->parse(nbits, bits, info, count);
- CPPUNIT_ASSERT(ret);
- CPPUNIT_ASSERT_EQUAL((size_t)1, info.size());
+ BOOST_REQUIRE(ret);
+ BOOST_REQUIRE_EQUAL((size_t)1, info.size());
pmt::pmt_t dict = info[0];
int payload_syms = pmt::to_long(pmt::dict_ref(dict, pmt::intern("payload symbols"),
@@ -256,9 +249,9 @@ qa_header_format::test_counter_parse()
int hdr_bits = (int)hdr_format->header_nbits();
int expected_bits = nbits - hdr_bits;
- CPPUNIT_ASSERT_EQUAL(expected_bits, payload_syms * bps);
- CPPUNIT_ASSERT_EQUAL(expected_bps, (uint16_t)bps);
- CPPUNIT_ASSERT_EQUAL(0, counter);
+ BOOST_REQUIRE_EQUAL(expected_bits, payload_syms * bps);
+ BOOST_REQUIRE_EQUAL(expected_bps, (uint16_t)bps);
+ BOOST_REQUIRE_EQUAL(0, counter);
volk_free(bytes);
volk_free(bits);
diff --git a/gr-digital/lib/qa_header_format.h b/gr-digital/lib/qa_header_format.h
deleted file mode 100644
index 281e8f4665..0000000000
--- a/gr-digital/lib/qa_header_format.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2015-2016 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef _QA_DIGITAL_HEADER_FORMAT_H_
-#define _QA_DIGITAL_HEADER_FORMAT_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_header_format : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_header_format);
- CPPUNIT_TEST(test_default_format);
- CPPUNIT_TEST(test_default_parse);
- CPPUNIT_TEST(test_counter_format);
- CPPUNIT_TEST(test_counter_parse);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- void test_default_format();
- void test_default_parse();
- void test_default_parse_soft();
- void test_counter_format();
- void test_counter_parse();
- void test_counter_parse_soft();
-};
-
-#endif /* _QA_DIGITAL_HEADER_FORMAT_H_ */