1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* -*- c++ -*- */
/*
* Copyright 2011,2012 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "qa_square2_ff.h"
#include <cppunit/TestAssert.h>
#include <vector>
#include <gr_top_block.h>
#include <gr_vector_source_f.h>
#include <gr_vector_sink_f.h>
#include <howto/square2_ff.h>
namespace gr {
namespace howto {
void
qa_square2_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();
square2_ff::sptr op = square2_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 */
|