diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-06-21 17:35:37 -0700 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-06-23 00:17:18 +0200 |
commit | 841dc1439224bb413b5cc663d40e0859e420b546 (patch) | |
tree | efaede402c03b2324471007ce17619bb17d321e0 | |
parent | 1f30b5b14f6d5a189a44565d0f7e4e8618bfa864 (diff) |
pmt: Replace QA test framework w/ Boost UTF
-rw-r--r-- | gnuradio-runtime/lib/CMakeLists.txt | 6 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/CMakeLists.txt | 35 | ||||
-rwxr-xr-x | gnuradio-runtime/lib/pmt/generate_unv.py | 33 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/qa_pmt.cc | 40 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/qa_pmt_prims.cc | 413 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/qa_pmt_prims.h | 77 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/qa_pmt_unv.cc (renamed from gnuradio-runtime/lib/pmt/qa_pmt.h) | 25 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/test_pmt.cc | 47 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/unv_qa_template.cc.t | 35 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/unv_qa_template.h.t | 33 |
10 files changed, 240 insertions, 504 deletions
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index 558138ec76..2e8312aaad 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -272,7 +272,6 @@ if(ENABLE_TESTING) qa_sincos.cc qa_fast_atan2f.cc ) - list(APPEND GR_TEST_TARGET_DEPS gnuradio-runtime gnuradio-pmt) foreach(qa_file ${test_gnuradio_math_sources}) GR_ADD_CPP_TEST("math_${qa_file}" @@ -280,5 +279,10 @@ if(ENABLE_TESTING) ) endforeach(qa_file) + # PMT tests: + include_directories(${CMAKE_CURRENT_BINARY_DIR}/pmt) + GR_ADD_CPP_TEST("pmt_prims" ${CMAKE_CURRENT_SOURCE_DIR}/pmt/qa_pmt_prims.cc) + GR_ADD_CPP_TEST("pmt_unv" ${CMAKE_CURRENT_SOURCE_DIR}/pmt/qa_pmt_unv.cc) + endif(ENABLE_TESTING) diff --git a/gnuradio-runtime/lib/pmt/CMakeLists.txt b/gnuradio-runtime/lib/pmt/CMakeLists.txt index 32c0e57a6a..469c569cdc 100644 --- a/gnuradio-runtime/lib/pmt/CMakeLists.txt +++ b/gnuradio-runtime/lib/pmt/CMakeLists.txt @@ -61,12 +61,11 @@ add_custom_command( ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv_int.h ${CMAKE_CURRENT_BINARY_DIR}/qa_pmt_unv.h ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv.cc - ${CMAKE_CURRENT_BINARY_DIR}/qa_pmt_unv.cc DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_unv.py ${CMAKE_CURRENT_SOURCE_DIR}/unv_template.h.t ${CMAKE_CURRENT_SOURCE_DIR}/unv_template.cc.t - ${CMAKE_CURRENT_SOURCE_DIR}/unv_qa_template.cc.t + ${CMAKE_CURRENT_SOURCE_DIR}/unv_qa_template.h.t COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} -c "import os, sys; srcdir='${CMAKE_CURRENT_SOURCE_DIR}'; sys.path.append(srcdir); os.environ['srcdir']=srcdir; from generate_unv import main; main()" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -129,35 +128,3 @@ if(ENABLE_STATIC_LIBS) ) endif(ENABLE_STATIC_LIBS) -######################################################################## -# Setup tests -######################################################################## -if(ENABLE_TESTING) -include(GrTest) - -######################################################################## -# Append gnuradio-runtime test sources -######################################################################## -list(APPEND test_gnuradio_pmt_sources - qa_pmt.cc - qa_pmt_prims.cc - ${CMAKE_CURRENT_BINARY_DIR}/qa_pmt_unv.cc -) - -include_directories(${CPPUNIT_INCLUDE_DIRS}) -link_directories(${CPPUNIT_LIBRARY_DIRS}) - -add_library(test-gnuradio-pmt SHARED ${test_gnuradio_pmt_sources}) -target_link_libraries(test-gnuradio-pmt gnuradio-runtime gnuradio-pmt - ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) - -######################################################################## -# Build the test executable -# Set the test environment so the build libs will be found under MSVC. -######################################################################## -list(APPEND GR_TEST_TARGET_DEPS test-gnuradio-pmt) -add_executable(gr_pmt_test test_pmt.cc) -target_link_libraries(gr_pmt_test test-gnuradio-pmt) -GR_ADD_TEST(gr-pmt-test gr_pmt_test) - -endif(ENABLE_TESTING) diff --git a/gnuradio-runtime/lib/pmt/generate_unv.py b/gnuradio-runtime/lib/pmt/generate_unv.py index 6218099fc1..c7daee9e45 100755 --- a/gnuradio-runtime/lib/pmt/generate_unv.py +++ b/gnuradio-runtime/lib/pmt/generate_unv.py @@ -81,8 +81,6 @@ includes = """ """ qa_includes = """ -#include <qa_pmt_unv.h> -#include <cppunit/TestAssert.h> #include <pmt/pmt.h> #include <stdio.h> @@ -146,34 +144,8 @@ def generate_cc(): def generate_qa_h(): - output_filename = 'qa_pmt_unv.h' - output = open(output_filename, 'w') - output.write(header) - output.write(guard_head(output_filename)) - - output.write(''' -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_pmt_unv : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_pmt_unv); -''') - for tag, typ in unv_types: - output.write(' CPPUNIT_TEST(test_%svector);\n' % (tag,)) - output.write('''\ - CPPUNIT_TEST_SUITE_END(); - - private: -''') - for tag, typ in unv_types: - output.write(' void test_%svector();\n' % (tag,)) - output.write('};\n') - output.write(guard_tail) - -def generate_qa_cc(): - template = open_src('unv_qa_template.cc.t', 'r').read() - output = open('qa_pmt_unv.cc', 'w') + template = open_src('unv_qa_template.h.t', 'r').read() + output = open('qa_pmt_unv.h', 'w') output.write(header) output.write(qa_includes) for tag, typ in unv_types: @@ -185,7 +157,6 @@ def main(): generate_h() generate_cc() generate_qa_h() - generate_qa_cc() if __name__ == '__main__': main() diff --git a/gnuradio-runtime/lib/pmt/qa_pmt.cc b/gnuradio-runtime/lib/pmt/qa_pmt.cc deleted file mode 100644 index a87f97e570..0000000000 --- a/gnuradio-runtime/lib/pmt/qa_pmt.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006 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 pmt into - * a single test suite. As you create new test cases, add them here. - */ - -#include <qa_pmt.h> -#include <qa_pmt_prims.h> -#include <qa_pmt_unv.h> - -CppUnit::TestSuite * -qa_pmt::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("pmt"); - - s->addTest(qa_pmt_prims::suite()); - s->addTest(qa_pmt_unv::suite()); - - return s; -} diff --git a/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc b/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc index 2b3ca32293..356cf95203 100644 --- a/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc +++ b/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc @@ -20,32 +20,30 @@ * Boston, MA 02110-1301, USA. */ -#include <qa_pmt_prims.h> -#include <cppunit/TestAssert.h> +#include <pmt/api.h> //reason: suppress warnings #include <gnuradio/messages/msg_passing.h> +#include <boost/test/unit_test.hpp> #include <boost/format.hpp> #include <cstdio> #include <cstring> #include <sstream> -void -qa_pmt_prims::test_symbols() -{ - CPPUNIT_ASSERT(!pmt::is_symbol(pmt::PMT_T)); - CPPUNIT_ASSERT(!pmt::is_symbol(pmt::PMT_F)); - CPPUNIT_ASSERT_THROW(pmt::symbol_to_string(pmt::PMT_F), pmt::wrong_type); +BOOST_AUTO_TEST_CASE(test_symbols) { + BOOST_CHECK(!pmt::is_symbol(pmt::PMT_T)); + BOOST_CHECK(!pmt::is_symbol(pmt::PMT_F)); + BOOST_CHECK_THROW(pmt::symbol_to_string(pmt::PMT_F), pmt::wrong_type); pmt::pmt_t sym1 = pmt::mp("test"); - CPPUNIT_ASSERT(pmt::is_symbol(sym1)); - CPPUNIT_ASSERT_EQUAL(std::string("test"), pmt::symbol_to_string(sym1)); - CPPUNIT_ASSERT(pmt::is_true(sym1)); - CPPUNIT_ASSERT(!pmt::is_false(sym1)); + BOOST_CHECK(pmt::is_symbol(sym1)); + BOOST_CHECK_EQUAL(std::string("test"), pmt::symbol_to_string(sym1)); + BOOST_CHECK(pmt::is_true(sym1)); + BOOST_CHECK(!pmt::is_false(sym1)); pmt::pmt_t sym2 = pmt::mp("foo"); pmt::pmt_t sym3 = pmt::mp("test"); - CPPUNIT_ASSERT_EQUAL(sym1, sym3); - CPPUNIT_ASSERT(sym1 != sym2); - CPPUNIT_ASSERT(sym1 == sym3); + BOOST_CHECK_EQUAL(sym1, sym3); + BOOST_CHECK(sym1 != sym2); + BOOST_CHECK(sym1 == sym3); static const int N = 2048; std::vector<pmt::pmt_t> v1(N); @@ -60,7 +58,7 @@ qa_pmt_prims::test_symbols() // confirm that they are all unique for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) - CPPUNIT_ASSERT(v1[i] != v1[j]); + BOOST_CHECK(v1[i] != v1[j]); // generate the same symbols again for (int i = 0; i < N; i++){ @@ -70,141 +68,127 @@ qa_pmt_prims::test_symbols() // confirm that we get the same ones back for (int i = 0; i < N; i++) - CPPUNIT_ASSERT(v1[i] == v2[i]); + BOOST_CHECK(v1[i] == v2[i]); } -void -qa_pmt_prims::test_booleans() -{ +BOOST_AUTO_TEST_CASE(test_booleans) { pmt::pmt_t sym = pmt::mp("test"); - CPPUNIT_ASSERT(pmt::is_bool(pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::is_bool(pmt::PMT_F)); - CPPUNIT_ASSERT(!pmt::is_bool(sym)); - CPPUNIT_ASSERT_EQUAL(pmt::from_bool(false), pmt::PMT_F); - CPPUNIT_ASSERT_EQUAL(pmt::from_bool(true), pmt::PMT_T); - CPPUNIT_ASSERT_EQUAL(false, pmt::to_bool(pmt::PMT_F)); - CPPUNIT_ASSERT_EQUAL(true, pmt::to_bool(pmt::PMT_T)); - CPPUNIT_ASSERT_THROW(pmt::to_bool(sym), pmt::wrong_type); + BOOST_CHECK(pmt::is_bool(pmt::PMT_T)); + BOOST_CHECK(pmt::is_bool(pmt::PMT_F)); + BOOST_CHECK(!pmt::is_bool(sym)); + BOOST_CHECK_EQUAL(pmt::from_bool(false), pmt::PMT_F); + BOOST_CHECK_EQUAL(pmt::from_bool(true), pmt::PMT_T); + BOOST_CHECK_EQUAL(false, pmt::to_bool(pmt::PMT_F)); + BOOST_CHECK_EQUAL(true, pmt::to_bool(pmt::PMT_T)); + BOOST_CHECK_THROW(pmt::to_bool(sym), pmt::wrong_type); } -void -qa_pmt_prims::test_integers() -{ +BOOST_AUTO_TEST_CASE(test_integers) { pmt::pmt_t p1 = pmt::from_long(1); pmt::pmt_t m1 = pmt::from_long(-1); - CPPUNIT_ASSERT(!pmt::is_integer(pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::is_integer(p1)); - CPPUNIT_ASSERT(pmt::is_integer(m1)); - CPPUNIT_ASSERT_THROW(pmt::to_long(pmt::PMT_T), pmt::wrong_type); - CPPUNIT_ASSERT_EQUAL(-1L, pmt::to_long(m1)); - CPPUNIT_ASSERT_EQUAL(1L, pmt::to_long(p1)); + BOOST_CHECK(!pmt::is_integer(pmt::PMT_T)); + BOOST_CHECK(pmt::is_integer(p1)); + BOOST_CHECK(pmt::is_integer(m1)); + BOOST_CHECK_THROW(pmt::to_long(pmt::PMT_T), pmt::wrong_type); + BOOST_CHECK_EQUAL(-1L, pmt::to_long(m1)); + BOOST_CHECK_EQUAL(1L, pmt::to_long(p1)); } -void -qa_pmt_prims::test_uint64s() -{ +BOOST_AUTO_TEST_CASE(test_uint64s) { pmt::pmt_t p1 = pmt::from_uint64((uint64_t)1); pmt::pmt_t m1 = pmt::from_uint64((uint64_t)8589934592ULL); - CPPUNIT_ASSERT(!pmt::is_uint64(pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::is_uint64(p1)); - CPPUNIT_ASSERT(pmt::is_uint64(m1)); - CPPUNIT_ASSERT_THROW(pmt::to_uint64(pmt::PMT_T), pmt::wrong_type); - CPPUNIT_ASSERT_EQUAL((uint64_t)8589934592ULL, (uint64_t)pmt::to_uint64(m1)); - CPPUNIT_ASSERT_EQUAL((uint64_t)1ULL, (uint64_t)pmt::to_uint64(p1)); + BOOST_CHECK(!pmt::is_uint64(pmt::PMT_T)); + BOOST_CHECK(pmt::is_uint64(p1)); + BOOST_CHECK(pmt::is_uint64(m1)); + BOOST_CHECK_THROW(pmt::to_uint64(pmt::PMT_T), pmt::wrong_type); + BOOST_CHECK_EQUAL((uint64_t)8589934592ULL, (uint64_t)pmt::to_uint64(m1)); + BOOST_CHECK_EQUAL((uint64_t)1ULL, (uint64_t)pmt::to_uint64(p1)); } -void -qa_pmt_prims::test_reals() -{ +BOOST_AUTO_TEST_CASE(test_reals) { pmt::pmt_t p1 = pmt::from_double(1); pmt::pmt_t m1 = pmt::from_double(-1); - CPPUNIT_ASSERT(!pmt::is_real(pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::is_real(p1)); - CPPUNIT_ASSERT(pmt::is_real(m1)); - CPPUNIT_ASSERT_THROW(pmt::to_double(pmt::PMT_T), pmt::wrong_type); - CPPUNIT_ASSERT_EQUAL(-1.0, pmt::to_double(m1)); - CPPUNIT_ASSERT_EQUAL(1.0, pmt::to_double(p1)); - CPPUNIT_ASSERT_EQUAL(1.0, pmt::to_double(pmt::from_long(1))); + BOOST_CHECK(!pmt::is_real(pmt::PMT_T)); + BOOST_CHECK(pmt::is_real(p1)); + BOOST_CHECK(pmt::is_real(m1)); + BOOST_CHECK_THROW(pmt::to_double(pmt::PMT_T), pmt::wrong_type); + BOOST_CHECK_EQUAL(-1.0, pmt::to_double(m1)); + BOOST_CHECK_EQUAL(1.0, pmt::to_double(p1)); + BOOST_CHECK_EQUAL(1.0, pmt::to_double(pmt::from_long(1))); pmt::pmt_t p2 = pmt::from_float(1); pmt::pmt_t m2 = pmt::from_float(-1); - CPPUNIT_ASSERT(pmt::is_real(p2)); - CPPUNIT_ASSERT(pmt::is_real(m2)); - CPPUNIT_ASSERT_THROW(pmt::to_float(pmt::PMT_T), pmt::wrong_type); - CPPUNIT_ASSERT_EQUAL(float(-1.0), pmt::to_float(m2)); - CPPUNIT_ASSERT_EQUAL(float(1.0), pmt::to_float(p2)); - CPPUNIT_ASSERT_EQUAL(float(1.0), pmt::to_float(pmt::from_long(1))); + BOOST_CHECK(pmt::is_real(p2)); + BOOST_CHECK(pmt::is_real(m2)); + BOOST_CHECK_THROW(pmt::to_float(pmt::PMT_T), pmt::wrong_type); + BOOST_CHECK_EQUAL(float(-1.0), pmt::to_float(m2)); + BOOST_CHECK_EQUAL(float(1.0), pmt::to_float(p2)); + BOOST_CHECK_EQUAL(float(1.0), pmt::to_float(pmt::from_long(1))); } -void -qa_pmt_prims::test_complexes() -{ +BOOST_AUTO_TEST_CASE(test_complexes) { pmt::pmt_t p1 = pmt::make_rectangular(2, -3); pmt::pmt_t m1 = pmt::make_rectangular(-3, 2); pmt::pmt_t p2 = pmt::from_complex(2, -3); pmt::pmt_t m2 = pmt::from_complex(-3, 2); pmt::pmt_t p3 = pmt::from_complex(std::complex<double>(2, -3)); pmt::pmt_t m3 = pmt::from_complex(std::complex<double>(-3, 2)); - CPPUNIT_ASSERT(!pmt::is_complex(pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::is_complex(p1)); - CPPUNIT_ASSERT(pmt::is_complex(m1)); - CPPUNIT_ASSERT(pmt::is_complex(p2)); - CPPUNIT_ASSERT(pmt::is_complex(m2)); - CPPUNIT_ASSERT(pmt::is_complex(p3)); - CPPUNIT_ASSERT(pmt::is_complex(m3)); - CPPUNIT_ASSERT_THROW(pmt::to_complex(pmt::PMT_T), pmt::wrong_type); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p1)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m1)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p2)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m2)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p3)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m3)); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt::to_complex(pmt::from_long(1))); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(1.0, 0), pmt::to_complex(pmt::from_double(1.0))); + BOOST_CHECK(!pmt::is_complex(pmt::PMT_T)); + BOOST_CHECK(pmt::is_complex(p1)); + BOOST_CHECK(pmt::is_complex(m1)); + BOOST_CHECK(pmt::is_complex(p2)); + BOOST_CHECK(pmt::is_complex(m2)); + BOOST_CHECK(pmt::is_complex(p3)); + BOOST_CHECK(pmt::is_complex(m3)); + BOOST_CHECK_THROW(pmt::to_complex(pmt::PMT_T), pmt::wrong_type); + BOOST_CHECK_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p1)); + BOOST_CHECK_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m1)); + BOOST_CHECK_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p2)); + BOOST_CHECK_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m2)); + BOOST_CHECK_EQUAL(std::complex<double>(2, -3), pmt::to_complex(p3)); + BOOST_CHECK_EQUAL(std::complex<double>(-3, 2), pmt::to_complex(m3)); + BOOST_CHECK_EQUAL(std::complex<double>(1.0, 0), pmt::to_complex(pmt::from_long(1))); + BOOST_CHECK_EQUAL(std::complex<double>(1.0, 0), pmt::to_complex(pmt::from_double(1.0))); } -void -qa_pmt_prims::test_pairs() -{ - CPPUNIT_ASSERT(pmt::is_null(pmt::PMT_NIL)); - CPPUNIT_ASSERT(!pmt::is_pair(pmt::PMT_NIL)); +BOOST_AUTO_TEST_CASE(test_pairs) { + BOOST_CHECK(pmt::is_null(pmt::PMT_NIL)); + BOOST_CHECK(!pmt::is_pair(pmt::PMT_NIL)); pmt::pmt_t s1 = pmt::mp("s1"); pmt::pmt_t s2 = pmt::mp("s2"); pmt::pmt_t s3 = pmt::mp("s3"); - CPPUNIT_ASSERT_EQUAL((size_t)0, pmt::length(pmt::PMT_NIL)); - CPPUNIT_ASSERT_THROW(pmt::length(s1), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::length(pmt::from_double(42)), pmt::wrong_type); + BOOST_CHECK_EQUAL((size_t)0, pmt::length(pmt::PMT_NIL)); + BOOST_CHECK_THROW(pmt::length(s1), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::length(pmt::from_double(42)), pmt::wrong_type); pmt::pmt_t c1 = pmt::cons(s1, pmt::PMT_NIL); - CPPUNIT_ASSERT(pmt::is_pair(c1)); - CPPUNIT_ASSERT(!pmt::is_pair(s1)); - CPPUNIT_ASSERT_EQUAL(s1, pmt::car(c1)); - CPPUNIT_ASSERT_EQUAL(pmt::PMT_NIL, pmt::cdr(c1)); - CPPUNIT_ASSERT_EQUAL((size_t) 1, pmt::length(c1)); + BOOST_CHECK(pmt::is_pair(c1)); + BOOST_CHECK(!pmt::is_pair(s1)); + BOOST_CHECK_EQUAL(s1, pmt::car(c1)); + BOOST_CHECK_EQUAL(pmt::PMT_NIL, pmt::cdr(c1)); + BOOST_CHECK_EQUAL((size_t) 1, pmt::length(c1)); pmt::pmt_t c3 = pmt::cons(s3, pmt::PMT_NIL); pmt::pmt_t c2 = pmt::cons(s2, c3); pmt::set_cdr(c1, c2); - CPPUNIT_ASSERT_EQUAL(c2, pmt::cdr(c1)); + BOOST_CHECK_EQUAL(c2, pmt::cdr(c1)); pmt::set_car(c1, s3); - CPPUNIT_ASSERT_EQUAL(s3, pmt::car(c1)); - CPPUNIT_ASSERT_EQUAL((size_t)1, pmt::length(c3)); - CPPUNIT_ASSERT_EQUAL((size_t)2, pmt::length(c2)); - - CPPUNIT_ASSERT_THROW(pmt::cdr(pmt::PMT_NIL), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::car(pmt::PMT_NIL), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::set_car(s1, pmt::PMT_NIL), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::set_cdr(s1, pmt::PMT_NIL), pmt::wrong_type); + BOOST_CHECK_EQUAL(s3, pmt::car(c1)); + BOOST_CHECK_EQUAL((size_t)1, pmt::length(c3)); + BOOST_CHECK_EQUAL((size_t)2, pmt::length(c2)); + + BOOST_CHECK_THROW(pmt::cdr(pmt::PMT_NIL), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::car(pmt::PMT_NIL), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::set_car(s1, pmt::PMT_NIL), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::set_cdr(s1, pmt::PMT_NIL), pmt::wrong_type); } -void -qa_pmt_prims::test_vectors() -{ +BOOST_AUTO_TEST_CASE(test_vectors) { static const size_t N = 3; pmt::pmt_t v1 = pmt::make_vector(N, pmt::PMT_NIL); - CPPUNIT_ASSERT_EQUAL(N, pmt::length(v1)); + BOOST_CHECK_EQUAL(N, pmt::length(v1)); pmt::pmt_t s0 = pmt::mp("s0"); pmt::pmt_t s1 = pmt::mp("s1"); pmt::pmt_t s2 = pmt::mp("s2"); @@ -213,32 +197,30 @@ qa_pmt_prims::test_vectors() pmt::vector_set(v1, 1, s1); pmt::vector_set(v1, 2, s2); - CPPUNIT_ASSERT_EQUAL(s0, pmt::vector_ref(v1, 0)); - CPPUNIT_ASSERT_EQUAL(s1, pmt::vector_ref(v1, 1)); - CPPUNIT_ASSERT_EQUAL(s2, pmt::vector_ref(v1, 2)); + BOOST_CHECK_EQUAL(s0, pmt::vector_ref(v1, 0)); + BOOST_CHECK_EQUAL(s1, pmt::vector_ref(v1, 1)); + BOOST_CHECK_EQUAL(s2, pmt::vector_ref(v1, 2)); - CPPUNIT_ASSERT_THROW(pmt::vector_ref(v1, N), pmt::out_of_range); - CPPUNIT_ASSERT_THROW(pmt::vector_set(v1, N, pmt::PMT_NIL), pmt::out_of_range); + BOOST_CHECK_THROW(pmt::vector_ref(v1, N), pmt::out_of_range); + BOOST_CHECK_THROW(pmt::vector_set(v1, N, pmt::PMT_NIL), pmt::out_of_range); pmt::vector_fill(v1, s0); for (size_t i = 0; i < N; i++) - CPPUNIT_ASSERT_EQUAL(s0, pmt::vector_ref(v1, i)); + BOOST_CHECK_EQUAL(s0, pmt::vector_ref(v1, i)); } static void check_tuple(size_t len, const std::vector<pmt::pmt_t> &s, pmt::pmt_t t) { - CPPUNIT_ASSERT_EQUAL(true, pmt::is_tuple(t)); - CPPUNIT_ASSERT_EQUAL(len, pmt::length(t)); + BOOST_CHECK_EQUAL(true, pmt::is_tuple(t)); + BOOST_CHECK_EQUAL(len, pmt::length(t)); for (size_t i = 0; i < len; i++) - CPPUNIT_ASSERT_EQUAL(s[i], pmt::tuple_ref(t, i)); + BOOST_CHECK_EQUAL(s[i], pmt::tuple_ref(t, i)); } -void -qa_pmt_prims::test_tuples() -{ +BOOST_AUTO_TEST_CASE(test_tuples) { pmt::pmt_t v = pmt::make_vector(10, pmt::PMT_NIL); std::vector<pmt::pmt_t> s(10); for (size_t i = 0; i < 10; i++){ @@ -257,10 +239,10 @@ qa_pmt_prims::test_tuples() t = pmt::make_tuple(s[0]); check_tuple(1, s, t); - CPPUNIT_ASSERT(pmt::is_vector(v)); - CPPUNIT_ASSERT(!pmt::is_tuple(v)); - CPPUNIT_ASSERT(pmt::is_tuple(t)); - CPPUNIT_ASSERT(!pmt::is_vector(t)); + BOOST_CHECK(pmt::is_vector(v)); + BOOST_CHECK(!pmt::is_tuple(v)); + BOOST_CHECK(pmt::is_tuple(t)); + BOOST_CHECK(!pmt::is_vector(t)); t = pmt::make_tuple(s[0], s[1]); check_tuple(2, s, t); @@ -290,29 +272,27 @@ qa_pmt_prims::test_tuples() check_tuple(10, s, t); t = pmt::make_tuple(s[0], s[1], s[2]); - CPPUNIT_ASSERT_THROW(pmt::tuple_ref(t, 3), pmt::out_of_range); - CPPUNIT_ASSERT_THROW(pmt::vector_ref(t, 0), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::tuple_ref(v, 0), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::tuple_ref(t, 3), pmt::out_of_range); + BOOST_CHECK_THROW(pmt::vector_ref(t, 0), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::tuple_ref(v, 0), pmt::wrong_type); t = pmt::make_tuple(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9]); pmt::pmt_t t2 = pmt::to_tuple(v); - CPPUNIT_ASSERT_EQUAL(size_t(10), pmt::length(v)); - CPPUNIT_ASSERT(pmt::equal(t, t2)); + BOOST_CHECK_EQUAL(size_t(10), pmt::length(v)); + BOOST_CHECK(pmt::equal(t, t2)); //std::cout << v << std::endl; //std::cout << t2 << std::endl; t = pmt::make_tuple(s[0], s[1], s[2]); pmt::pmt_t list0 = pmt::list3(s[0], s[1], s[2]); - CPPUNIT_ASSERT_EQUAL(size_t(3), pmt::length(list0)); + BOOST_CHECK_EQUAL(size_t(3), pmt::length(list0)); t2 = pmt::to_tuple(list0); - CPPUNIT_ASSERT_EQUAL(size_t(3), pmt::length(t2)); - CPPUNIT_ASSERT(pmt::equal(t, t2)); + BOOST_CHECK_EQUAL(size_t(3), pmt::length(t2)); + BOOST_CHECK(pmt::equal(t, t2)); } -void -qa_pmt_prims::test_equivalence() -{ +BOOST_AUTO_TEST_CASE(test_equivalence) { pmt::pmt_t s0 = pmt::mp("s0"); pmt::pmt_t s1 = pmt::mp("s1"); pmt::pmt_t s2 = pmt::mp("s2"); @@ -324,37 +304,35 @@ qa_pmt_prims::test_equivalence() pmt::pmt_t r1 = pmt::from_double(42); pmt::pmt_t r2 = pmt::from_double(43); - CPPUNIT_ASSERT(pmt::eq(s0, s0)); - CPPUNIT_ASSERT(!pmt::eq(s0, s1)); - CPPUNIT_ASSERT(pmt::eqv(s0, s0)); - CPPUNIT_ASSERT(!pmt::eqv(s0, s1)); + BOOST_CHECK(pmt::eq(s0, s0)); + BOOST_CHECK(!pmt::eq(s0, s1)); + BOOST_CHECK(pmt::eqv(s0, s0)); + BOOST_CHECK(!pmt::eqv(s0, s1)); - CPPUNIT_ASSERT(pmt::eqv(i0, i1)); - CPPUNIT_ASSERT(pmt::eqv(r0, r1)); - CPPUNIT_ASSERT(!pmt::eqv(r0, r2)); - CPPUNIT_ASSERT(!pmt::eqv(i0, r0)); + BOOST_CHECK(pmt::eqv(i0, i1)); + BOOST_CHECK(pmt::eqv(r0, r1)); + BOOST_CHECK(!pmt::eqv(r0, r2)); + BOOST_CHECK(!pmt::eqv(i0, r0)); - CPPUNIT_ASSERT(!pmt::eq(list0, list1)); - CPPUNIT_ASSERT(!pmt::eqv(list0, list1)); - CPPUNIT_ASSERT(pmt::equal(list0, list1)); + BOOST_CHECK(!pmt::eq(list0, list1)); + BOOST_CHECK(!pmt::eqv(list0, list1)); + BOOST_CHECK(pmt::equal(list0, list1)); pmt::pmt_t v0 = pmt::make_vector(3, s0); pmt::pmt_t v1 = pmt::make_vector(3, s0); pmt::pmt_t v2 = pmt::make_vector(4, s0); - CPPUNIT_ASSERT(!pmt::eqv(v0, v1)); - CPPUNIT_ASSERT(pmt::equal(v0, v1)); - CPPUNIT_ASSERT(!pmt::equal(v0, v2)); + BOOST_CHECK(!pmt::eqv(v0, v1)); + BOOST_CHECK(pmt::equal(v0, v1)); + BOOST_CHECK(!pmt::equal(v0, v2)); pmt::vector_set(v0, 0, list0); pmt::vector_set(v0, 1, list0); pmt::vector_set(v1, 0, list1); pmt::vector_set(v1, 1, list1); - CPPUNIT_ASSERT(pmt::equal(v0, v1)); + BOOST_CHECK(pmt::equal(v0, v1)); } -void -qa_pmt_prims::test_misc() -{ +BOOST_AUTO_TEST_CASE(test_misc) { pmt::pmt_t k0 = pmt::mp("k0"); pmt::pmt_t k1 = pmt::mp("k1"); pmt::pmt_t k2 = pmt::mp("k2"); @@ -367,20 +345,18 @@ qa_pmt_prims::test_misc() pmt::pmt_t p2 = pmt::cons(k2, v2); pmt::pmt_t alist = pmt::cons(p0, pmt::cons(p1, pmt::cons(p2, pmt::PMT_NIL))); - CPPUNIT_ASSERT(pmt::eq(p1, pmt::assv(k1, alist))); - CPPUNIT_ASSERT(pmt::eq(pmt::PMT_F, pmt::assv(k3, alist))); + BOOST_CHECK(pmt::eq(p1, pmt::assv(k1, alist))); + BOOST_CHECK(pmt::eq(pmt::PMT_F, pmt::assv(k3, alist))); pmt::pmt_t keys = pmt::cons(k0, pmt::cons(k1, pmt::cons(k2, pmt::PMT_NIL))); pmt::pmt_t vals = pmt::cons(v0, pmt::cons(v1, pmt::cons(v2, pmt::PMT_NIL))); - CPPUNIT_ASSERT(pmt::equal(keys, pmt::map(pmt::car, alist))); - CPPUNIT_ASSERT(pmt::equal(vals, pmt::map(pmt::cdr, alist))); + BOOST_CHECK(pmt::equal(keys, pmt::map(pmt::car, alist))); + BOOST_CHECK(pmt::equal(vals, pmt::map(pmt::cdr, alist))); } -void -qa_pmt_prims::test_dict() -{ +BOOST_AUTO_TEST_CASE(test_dict) { pmt::pmt_t dict = pmt::make_dict(); - CPPUNIT_ASSERT(pmt::is_dict(dict)); + BOOST_CHECK(pmt::is_dict(dict)); pmt::pmt_t k0 = pmt::mp("k0"); pmt::pmt_t k1 = pmt::mp("k1"); @@ -392,39 +368,35 @@ qa_pmt_prims::test_dict() pmt::pmt_t v3 = pmt::mp("v3"); pmt::pmt_t not_found = pmt::cons(pmt::PMT_NIL, pmt::PMT_NIL); - CPPUNIT_ASSERT(!pmt::dict_has_key(dict, k0)); + BOOST_CHECK(!pmt::dict_has_key(dict, k0)); dict = pmt::dict_add(dict, k0, v0); - CPPUNIT_ASSERT(pmt::dict_has_key(dict, k0)); - CPPUNIT_ASSERT(pmt::eqv(pmt::dict_ref(dict, k0, not_found), v0)); - CPPUNIT_ASSERT(pmt::eqv(pmt::dict_ref(dict, k1, not_found), not_found)); + BOOST_CHECK(pmt::dict_has_key(dict, k0)); + BOOST_CHECK(pmt::eqv(pmt::dict_ref(dict, k0, not_found), v0)); + BOOST_CHECK(pmt::eqv(pmt::dict_ref(dict, k1, not_found), not_found)); dict = pmt::dict_add(dict, k1, v1); dict = pmt::dict_add(dict, k2, v2); - CPPUNIT_ASSERT(pmt::eqv(pmt::dict_ref(dict, k1, not_found), v1)); + BOOST_CHECK(pmt::eqv(pmt::dict_ref(dict, k1, not_found), v1)); dict = pmt::dict_add(dict, k1, v3); - CPPUNIT_ASSERT(pmt::eqv(pmt::dict_ref(dict, k1, not_found), v3)); + BOOST_CHECK(pmt::eqv(pmt::dict_ref(dict, k1, not_found), v3)); pmt::pmt_t keys = pmt::list3(k1, k2, k0); pmt::pmt_t vals = pmt::list3(v3, v2, v0); //std::cout << "pmt::dict_keys: " << pmt::dict_keys(dict) << std::endl; //std::cout << "pmt::dict_values: " << pmt::dict_values(dict) << std::endl; - CPPUNIT_ASSERT(pmt::equal(keys, pmt::dict_keys(dict))); - CPPUNIT_ASSERT(pmt::equal(vals, pmt::dict_values(dict))); + BOOST_CHECK(pmt::equal(keys, pmt::dict_keys(dict))); + BOOST_CHECK(pmt::equal(vals, pmt::dict_values(dict))); } -void -qa_pmt_prims::test_io() -{ +BOOST_AUTO_TEST_CASE(test_io) { pmt::pmt_t k0 = pmt::mp("k0"); pmt::pmt_t k1 = pmt::mp("k1"); pmt::pmt_t k2 = pmt::mp("k2"); pmt::pmt_t k3 = pmt::mp("k3"); - CPPUNIT_ASSERT_EQUAL(std::string("k0"), pmt::write_string(k0)); + BOOST_CHECK_EQUAL(std::string("k0"), pmt::write_string(k0)); } -void -qa_pmt_prims::test_lists() -{ +BOOST_AUTO_TEST_CASE(test_lists) { pmt::pmt_t s0 = pmt::mp("s0"); pmt::pmt_t s1 = pmt::mp("s1"); pmt::pmt_t s2 = pmt::mp("s2"); @@ -433,7 +405,7 @@ qa_pmt_prims::test_lists() pmt::pmt_t l1 = pmt::list4(s0, s1, s2, s3); pmt::pmt_t l2 = pmt::list3(s0, s1, s2); pmt::pmt_t l3 = pmt::list_add(l2, s3); - CPPUNIT_ASSERT(pmt::equal(l1, l3)); + BOOST_CHECK(pmt::equal(l1, l3)); } // ------------------------------------------------------------------------ @@ -460,9 +432,7 @@ std::ostream& operator<<(std::ostream &os, const foo obj) return os; } -void -qa_pmt_prims::test_any() -{ +BOOST_AUTO_TEST_CASE(test_any) { boost::any a0; boost::any a1; boost::any a2; @@ -475,13 +445,13 @@ qa_pmt_prims::test_any() pmt::pmt_t p1 = pmt::make_any(a1); pmt::pmt_t p2 = pmt::make_any(a2); - CPPUNIT_ASSERT_EQUAL(std::string("Hello!"), + BOOST_CHECK_EQUAL(std::string("Hello!"), boost::any_cast<std::string>(pmt::any_ref(p0))); - CPPUNIT_ASSERT_EQUAL(42, + BOOST_CHECK_EQUAL(42, boost::any_cast<int>(pmt::any_ref(p1))); - CPPUNIT_ASSERT_EQUAL(foo(3.250, 21), + BOOST_CHECK_EQUAL(foo(3.250, 21), boost::any_cast<foo>(pmt::any_ref(p2))); } @@ -490,16 +460,14 @@ qa_pmt_prims::test_any() class qa_pmt_msg_accepter_nop : public gr::messages::msg_accepter { public: - qa_pmt_msg_accepter_nop(){}; + qa_pmt_msg_accepter_nop(){} ~qa_pmt_msg_accepter_nop(); - void post(pmt::pmt_t,pmt::pmt_t){}; + void post(pmt::pmt_t,pmt::pmt_t){} }; qa_pmt_msg_accepter_nop::~qa_pmt_msg_accepter_nop(){} -void -qa_pmt_prims::test_msg_accepter() -{ +BOOST_AUTO_TEST_CASE(test_msg_accepter) { pmt::pmt_t sym = pmt::mp("my-symbol"); boost::any a0; @@ -510,10 +478,10 @@ qa_pmt_prims::test_msg_accepter() gr::messages::msg_accepter_sptr(new qa_pmt_msg_accepter_nop()); pmt::pmt_t p1 = pmt::make_msg_accepter(ma0); - CPPUNIT_ASSERT_EQUAL(ma0.get(), pmt::msg_accepter_ref(p1).get()); + BOOST_CHECK_EQUAL(ma0.get(), pmt::msg_accepter_ref(p1).get()); - CPPUNIT_ASSERT_THROW(pmt::msg_accepter_ref(sym), pmt::wrong_type); - CPPUNIT_ASSERT_THROW(pmt::msg_accepter_ref(p0), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::msg_accepter_ref(sym), pmt::wrong_type); + BOOST_CHECK_THROW(pmt::msg_accepter_ref(p0), pmt::wrong_type); // just confirm interfaces on send are OK pmt::pmt_t port(pmt::intern("port")); @@ -525,9 +493,7 @@ qa_pmt_prims::test_msg_accepter() // ------------------------------------------------------------------------ -void -qa_pmt_prims::test_serialize() -{ +BOOST_AUTO_TEST_CASE(test_serialize) { std::stringbuf sb; // fake channel pmt::pmt_t a = pmt::mp("a"); pmt::pmt_t b = pmt::mp("b"); @@ -552,20 +518,20 @@ qa_pmt_prims::test_serialize() // read it back - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::PMT_NIL)); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::mp("foobarvia"))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::from_long(123456789))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::from_long(-123456789))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::cons(pmt::PMT_NIL, pmt::PMT_NIL))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::cons(a, b))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::list1(a))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::list2(a, b))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::list3(a, b, c))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::list3(a, pmt::list3(c, b, a), c))); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::PMT_T)); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::PMT_F)); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::PMT_NIL)); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::mp("foobarvia"))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::from_long(123456789))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::from_long(-123456789))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::cons(pmt::PMT_NIL, pmt::PMT_NIL))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::cons(a, b))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::list1(a))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::list2(a, b))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::list3(a, b, c))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::list3(a, pmt::list3(c, b, a), c))); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::PMT_T)); + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::PMT_F)); - CPPUNIT_ASSERT(pmt::equal(pmt::deserialize(sb), pmt::PMT_EOF)); // last item + BOOST_CHECK(pmt::equal(pmt::deserialize(sb), pmt::PMT_EOF)); // last item // FIXME add tests for real, complex, vector, uniform-vector, dict @@ -573,9 +539,7 @@ qa_pmt_prims::test_serialize() } -void -qa_pmt_prims::test_sets() -{ +BOOST_AUTO_TEST_CASE(test_sets) { pmt::pmt_t s1 = pmt::mp("s1"); pmt::pmt_t s2 = pmt::mp("s2"); pmt::pmt_t s3 = pmt::mp("s3"); @@ -584,29 +548,28 @@ qa_pmt_prims::test_sets() pmt::pmt_t l2 = pmt::list2(s2,s3); pmt::pmt_t l3 = pmt::list3(s1,s2,s3); - CPPUNIT_ASSERT(pmt::is_pair(pmt::memq(s1,l1))); - CPPUNIT_ASSERT(pmt::is_false(pmt::memq(s3,l1))); + BOOST_CHECK(pmt::is_pair(pmt::memq(s1,l1))); + BOOST_CHECK(pmt::is_false(pmt::memq(s3,l1))); - CPPUNIT_ASSERT(pmt::subsetp(l1,l3)); - CPPUNIT_ASSERT(pmt::subsetp(l2,l3)); - CPPUNIT_ASSERT(!pmt::subsetp(l1,l2)); - CPPUNIT_ASSERT(!pmt::subsetp(l2,l1)); - CPPUNIT_ASSERT(!pmt::subsetp(l3,l2)); + BOOST_CHECK(pmt::subsetp(l1,l3)); + BOOST_CHECK(pmt::subsetp(l2,l3)); + BOOST_CHECK(!pmt::subsetp(l1,l2)); + BOOST_CHECK(!pmt::subsetp(l2,l1)); + BOOST_CHECK(!pmt::subsetp(l3,l2)); } -void -qa_pmt_prims::test_sugar() -{ - CPPUNIT_ASSERT(pmt::is_symbol(pmt::mp("my-symbol"))); - CPPUNIT_ASSERT_EQUAL((long) 10, pmt::to_long(pmt::mp(10))); - CPPUNIT_ASSERT_EQUAL((double) 1e6, pmt::to_double(pmt::mp(1e6))); - CPPUNIT_ASSERT_EQUAL(std::complex<double>(2, 3), +BOOST_AUTO_TEST_CASE(test_sugar) { + BOOST_CHECK(pmt::is_symbol(pmt::mp("my-symbol"))); + BOOST_CHECK_EQUAL((long) 10, pmt::to_long(pmt::mp(10))); + BOOST_CHECK_EQUAL((double) 1e6, pmt::to_double(pmt::mp(1e6))); + BOOST_CHECK_EQUAL(std::complex<double>(2, 3), pmt::to_complex(pmt::mp(std::complex<double>(2, 3)))); int buf[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; pmt::pmt_t blob = pmt::mp(buf, sizeof(buf)); const void *data = pmt::blob_data(blob); size_t nbytes = pmt::blob_length(blob); - CPPUNIT_ASSERT_EQUAL(sizeof(buf), nbytes); - CPPUNIT_ASSERT(memcmp(buf, data, nbytes) == 0); + BOOST_CHECK_EQUAL(sizeof(buf), nbytes); + BOOST_CHECK(memcmp(buf, data, nbytes) == 0); } + diff --git a/gnuradio-runtime/lib/pmt/qa_pmt_prims.h b/gnuradio-runtime/lib/pmt/qa_pmt_prims.h deleted file mode 100644 index f2f3dd77f7..0000000000 --- a/gnuradio-runtime/lib/pmt/qa_pmt_prims.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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 INCLUDED_QA_PMT_PRIMS_H -#define INCLUDED_QA_PMT_PRIMS_H - -#include <gnuradio/attributes.h> -#include <pmt/api.h> //reason: suppress warnings -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class __GR_ATTR_EXPORT qa_pmt_prims : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_pmt_prims); - CPPUNIT_TEST(test_symbols); - CPPUNIT_TEST(test_booleans); - CPPUNIT_TEST(test_integers); - CPPUNIT_TEST(test_uint64s); - CPPUNIT_TEST(test_reals); - CPPUNIT_TEST(test_complexes); - CPPUNIT_TEST(test_pairs); - CPPUNIT_TEST(test_vectors); - CPPUNIT_TEST(test_tuples); - CPPUNIT_TEST(test_equivalence); - CPPUNIT_TEST(test_misc); - CPPUNIT_TEST(test_dict); - CPPUNIT_TEST(test_any); - CPPUNIT_TEST(test_msg_accepter); - CPPUNIT_TEST(test_io); - CPPUNIT_TEST(test_lists); - CPPUNIT_TEST(test_serialize); - CPPUNIT_TEST(test_sets); - CPPUNIT_TEST(test_sugar); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_symbols(); - void test_booleans(); - void test_integers(); - void test_uint64s(); - void test_reals(); - void test_complexes(); - void test_pairs(); - void test_vectors(); - void test_tuples(); - void test_equivalence(); - void test_misc(); - void test_dict(); - void test_any(); - void test_msg_accepter(); - void test_io(); - void test_lists(); - void test_serialize(); - void test_sets(); - void test_sugar(); -}; - -#endif /* INCLUDED_QA_PMT_PRIMS_H */ - diff --git a/gnuradio-runtime/lib/pmt/qa_pmt.h b/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc index 9293a076a6..66d0d6d438 100644 --- a/gnuradio-runtime/lib/pmt/qa_pmt.h +++ b/gnuradio-runtime/lib/pmt/qa_pmt_unv.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,18 +20,15 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_QA_PMT_H -#define INCLUDED_QA_PMT_H +// We need a non-generated C++ file for CMake, all the actual test cases are +// generated from the template and written to qa_pmt_unv.h -#include <gnuradio/attributes.h> -#include <cppunit/TestSuite.h> +#include <pmt/api.h> //reason: suppress warnings +#include <gnuradio/messages/msg_passing.h> +#include <boost/test/unit_test.hpp> +#include <boost/format.hpp> +#include <cstdio> +#include <cstring> +#include <sstream> -//! collect all the tests for pmt - -class __GR_ATTR_EXPORT qa_pmt { - public: - //! return suite of tests for all of pmt - static CppUnit::TestSuite *suite (); -}; - -#endif /* INCLUDED_QA_PMT_H */ +#include "qa_pmt_unv.h" diff --git a/gnuradio-runtime/lib/pmt/test_pmt.cc b/gnuradio-runtime/lib/pmt/test_pmt.cc deleted file mode 100644 index 403bf64cd0..0000000000 --- a/gnuradio-runtime/lib/pmt/test_pmt.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2013 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gnuradio/unittests.h> -#include <qa_pmt.h> -#include <fstream> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gnuradio_runtime_runtime.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest(qa_pmt::suite()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run("", false); - - return was_successful ? 0 : 1; -} diff --git a/gnuradio-runtime/lib/pmt/unv_qa_template.cc.t b/gnuradio-runtime/lib/pmt/unv_qa_template.cc.t deleted file mode 100644 index ea675cee16..0000000000 --- a/gnuradio-runtime/lib/pmt/unv_qa_template.cc.t +++ /dev/null @@ -1,35 +0,0 @@ -void -qa_pmt_unv::test_@TAG@vector() -{ - static const size_t N = 3; - pmt::pmt_t v1 = pmt::make_@TAG@vector(N, 0); - CPPUNIT_ASSERT_EQUAL(N, pmt::length(v1)); - @TYPE@ s0 = @TYPE@(10); - @TYPE@ s1 = @TYPE@(20); - @TYPE@ s2 = @TYPE@(30); - - pmt::@TAG@vector_set(v1, 0, s0); - pmt::@TAG@vector_set(v1, 1, s1); - pmt::@TAG@vector_set(v1, 2, s2); - - CPPUNIT_ASSERT_EQUAL(s0, pmt::@TAG@vector_ref(v1, 0)); - CPPUNIT_ASSERT_EQUAL(s1, pmt::@TAG@vector_ref(v1, 1)); - CPPUNIT_ASSERT_EQUAL(s2, pmt::@TAG@vector_ref(v1, 2)); - - CPPUNIT_ASSERT_THROW(pmt::@TAG@vector_ref(v1, N), pmt::out_of_range); - CPPUNIT_ASSERT_THROW(pmt::@TAG@vector_set(v1, N, @TYPE@(0)), pmt::out_of_range); - - size_t len; - const @TYPE@ *rd = pmt::@TAG@vector_elements(v1, len); - CPPUNIT_ASSERT_EQUAL(len, N); - CPPUNIT_ASSERT_EQUAL(s0, rd[0]); - CPPUNIT_ASSERT_EQUAL(s1, rd[1]); - CPPUNIT_ASSERT_EQUAL(s2, rd[2]); - - @TYPE@ *wr = pmt::@TAG@vector_writable_elements(v1, len); - CPPUNIT_ASSERT_EQUAL(len, N); - wr[0] = @TYPE@(0); - CPPUNIT_ASSERT_EQUAL(@TYPE@(0), wr[0]); - CPPUNIT_ASSERT_EQUAL(s1, wr[1]); - CPPUNIT_ASSERT_EQUAL(s2, wr[2]); -} diff --git a/gnuradio-runtime/lib/pmt/unv_qa_template.h.t b/gnuradio-runtime/lib/pmt/unv_qa_template.h.t new file mode 100644 index 0000000000..5a498f482c --- /dev/null +++ b/gnuradio-runtime/lib/pmt/unv_qa_template.h.t @@ -0,0 +1,33 @@ +BOOST_AUTO_TEST_CASE(test_@TAG@vector) { + static const size_t N = 3; + pmt::pmt_t v1 = pmt::make_@TAG@vector(N, 0); + BOOST_CHECK_EQUAL(N, pmt::length(v1)); + @TYPE@ s0 = @TYPE@(10); + @TYPE@ s1 = @TYPE@(20); + @TYPE@ s2 = @TYPE@(30); + + pmt::@TAG@vector_set(v1, 0, s0); + pmt::@TAG@vector_set(v1, 1, s1); + pmt::@TAG@vector_set(v1, 2, s2); + + BOOST_CHECK_EQUAL(s0, pmt::@TAG@vector_ref(v1, 0)); + BOOST_CHECK_EQUAL(s1, pmt::@TAG@vector_ref(v1, 1)); + BOOST_CHECK_EQUAL(s2, pmt::@TAG@vector_ref(v1, 2)); + + BOOST_CHECK_THROW(pmt::@TAG@vector_ref(v1, N), pmt::out_of_range); + BOOST_CHECK_THROW(pmt::@TAG@vector_set(v1, N, @TYPE@(0)), pmt::out_of_range); + + size_t len; + const @TYPE@ *rd = pmt::@TAG@vector_elements(v1, len); + BOOST_CHECK_EQUAL(len, N); + BOOST_CHECK_EQUAL(s0, rd[0]); + BOOST_CHECK_EQUAL(s1, rd[1]); + BOOST_CHECK_EQUAL(s2, rd[2]); + + @TYPE@ *wr = pmt::@TAG@vector_writable_elements(v1, len); + BOOST_CHECK_EQUAL(len, N); + wr[0] = @TYPE@(0); + BOOST_CHECK_EQUAL(@TYPE@(0), wr[0]); + BOOST_CHECK_EQUAL(s1, wr[1]); + BOOST_CHECK_EQUAL(s2, wr[2]); +} |