diff options
author | Tom Rondeau <trondeau@vt.edu> | 2012-09-30 21:01:23 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2012-09-30 21:01:23 -0400 |
commit | f37d62121f091b16fd07b418fef5f8f244c49b6f (patch) | |
tree | 579c6e308286b1e05b2d7f1cf8d5429401113293 /gr-howto-write-a-block/lib/qa_square_ff.cc | |
parent | 505bab9a6c43ef7fd3c815fa92bb90a05a9f2fac (diff) |
howto: moving C++ QA code to cppunit.
Diffstat (limited to 'gr-howto-write-a-block/lib/qa_square_ff.cc')
-rw-r--r-- | gr-howto-write-a-block/lib/qa_square_ff.cc | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/gr-howto-write-a-block/lib/qa_square_ff.cc b/gr-howto-write-a-block/lib/qa_square_ff.cc index bf474e7155..dedd934e16 100644 --- a/gr-howto-write-a-block/lib/qa_square_ff.cc +++ b/gr-howto-write-a-block/lib/qa_square_ff.cc @@ -19,14 +19,45 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <boost/test/unit_test.hpp> +#include "qa_square_ff.h" +#include <cppunit/TestAssert.h> -BOOST_AUTO_TEST_CASE(qa_square_ff_t1){ - BOOST_CHECK_EQUAL(2 + 2, 4); - // TODO BOOST_* test macros here -} +#include <vector> +#include <gr_top_block.h> +#include <gr_vector_source_f.h> +#include <gr_vector_sink_f.h> +#include <howto/square_ff.h> -BOOST_AUTO_TEST_CASE(qa_square_ff_t2){ - BOOST_CHECK_EQUAL(2 + 2, 4); - // TODO BOOST_* test macros here -} +namespace gr { + namespace howto { + + void + qa_square_ff::t1() + { + std::vector<float> data(5,0); + std::vector<float> result(5,0); + std::vector<float> output(5,0); + for(size_t i = 0; i < data.size(); i++) { + data[i] = i; + result[i] = i*i; + } + + gr_top_block_sptr tb = gr_make_top_block("dial_tone"); + gr_vector_source_f_sptr src = gr_make_vector_source_f(data); + gr_vector_sink_f_sptr snk = gr_make_vector_sink_f(); + + square_ff::sptr op = square_ff::make(); + + tb->connect(src, 0, op, 0); + tb->connect(op, 0, snk, 0); + tb->run(); + + output = snk->data(); + + for(size_t i = 0; i < data.size(); i++) { + CPPUNIT_ASSERT_DOUBLES_EQUAL(output[i], result[i], 0.0001); + } + } + + } /* namespace howto */ +} /* namespace gr */ |