From f2d5299a3f7dd5baa795a27c2864b2cfe67edb37 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sun, 14 Nov 2010 13:26:59 -0800 Subject: Add tests that show that vector> is not working... --- gnuradio-core/src/guile/tests/general_ctors.test | 22 ++++++++++++++ gnuradio-core/src/lib/general/Makefile.am | 3 ++ gnuradio-core/src/lib/general/complex_vec_test.cc | 37 +++++++++++++++++++++++ gnuradio-core/src/lib/general/complex_vec_test.h | 15 +++++++++ gnuradio-core/src/lib/general/complex_vec_test.i | 12 ++++++++ gnuradio-core/src/lib/general/general.i | 2 ++ 6 files changed, 91 insertions(+) create mode 100644 gnuradio-core/src/lib/general/complex_vec_test.cc create mode 100644 gnuradio-core/src/lib/general/complex_vec_test.h create mode 100644 gnuradio-core/src/lib/general/complex_vec_test.i (limited to 'gnuradio-core/src') diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test index 75c0f0bd4..a18766400 100644 --- a/gnuradio-core/src/guile/tests/general_ctors.test +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -28,6 +28,28 @@ (use-modules (gnuradio test-suite lib)) (use-modules (gnuradio core)) (use-modules (oop goops)) +(use-modules (ice-9 format)) + + +(define (verbose-equal? expected actual) + (cond ((equal? expected actual) #t) + (else + (format #t "Expected:\n~y\n" expected) + (format #t "Actual:\n~y\n" actual) + #f))) + + +;;; Test complex scalars +(pass-if (equal? 5.0+5.0i (gr:complex-scalar-test0))) +(pass-if (equal? 1.5+0.5i (gr:complex-scalar-test1 1+1i))) + +;;; Test complex vectors +(pass-if (verbose-equal? #(0+0i 1+1i 2+2i 3+3i 4+4i) + (gr:complex-vec-test0))) + +(pass-if (verbose-equal? #(1.5+0.5i 2.5+1.5i 3.5+2.5i) + (gr:complex-vec-test1 #(1+1i 2+2i 3+3i)))) + ;;; Add test code for all constructors in these files diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 3d8a42805..735795789 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -34,6 +34,7 @@ EXTRA_DIST = \ gr_constants.cc.in libgeneral_la_SOURCES = \ + complex_vec_test.cc \ gr_additive_scrambler_bb.cc \ gr_agc_cc.cc \ gr_agc_ff.cc \ @@ -188,6 +189,7 @@ libgeneral_qa_la_SOURCES = \ qa_gri_lfsr.cc grinclude_HEADERS = \ + complex_vec_test.h \ gr_additive_scrambler_bb.h \ gr_agc_cc.h \ gr_agc_ff.h \ @@ -359,6 +361,7 @@ noinst_HEADERS = \ if PYTHON swiginclude_HEADERS = \ + complex_vec_test.i \ general.i \ gr_additive_scrambler_bb.i \ gr_agc_cc.i \ diff --git a/gnuradio-core/src/lib/general/complex_vec_test.cc b/gnuradio-core/src/lib/general/complex_vec_test.cc new file mode 100644 index 000000000..21bca1765 --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.cc @@ -0,0 +1,37 @@ +#include +#include + +std::vector > +complex_vec_test0() +{ + std::vector > r(5); + + for (size_t i = 0; i < r.size(); i++) + r[i] = std::complex(i, i); + + return r; +} + +std::vector > +complex_vec_test1(const std::vector > &input) +{ + std::vector > r(input.size()); + + for (size_t i = 0; i < input.size(); i++) + r[i] = std::complex(input[i].real()+0.5, input[i].imag()-0.5); + + return r; +} + +std::complex +complex_scalar_test0() +{ + return std::complex(5, 5); +} + +std::complex +complex_scalar_test1(std::complex input) +{ + return std::complex(input.real()+0.5, input.imag()-0.5); +} + diff --git a/gnuradio-core/src/lib/general/complex_vec_test.h b/gnuradio-core/src/lib/general/complex_vec_test.h new file mode 100644 index 000000000..f1a8a14e2 --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.h @@ -0,0 +1,15 @@ +#include +#include + +std::vector > +complex_vec_test0(); + +std::vector > +complex_vec_test1(const std::vector > &input); + +std::complex +complex_scalar_test0(); + +std::complex +complex_scalar_test1(std::complex input); + diff --git a/gnuradio-core/src/lib/general/complex_vec_test.i b/gnuradio-core/src/lib/general/complex_vec_test.i new file mode 100644 index 000000000..1c62cfda2 --- /dev/null +++ b/gnuradio-core/src/lib/general/complex_vec_test.i @@ -0,0 +1,12 @@ +std::vector > +complex_vec_test0(); + +std::vector > +complex_vec_test1(const std::vector > &input); + +std::complex +complex_scalar_test0(); + +std::complex +complex_scalar_test1(std::complex input); + diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 3ad40b218..2c86a6240 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -141,6 +141,7 @@ #include #include #include +#include %} %include "gr_nop.i" @@ -262,3 +263,4 @@ %include "gr_copy.i" %include "gr_fll_band_edge_cc.i" %include "gr_additive_scrambler_bb.i" +%include "complex_vec_test.i" -- cgit