summaryrefslogtreecommitdiff
path: root/gr-howto-write-a-block/swig/howto.test
diff options
context:
space:
mode:
Diffstat (limited to 'gr-howto-write-a-block/swig/howto.test')
-rw-r--r--gr-howto-write-a-block/swig/howto.test69
1 files changed, 69 insertions, 0 deletions
diff --git a/gr-howto-write-a-block/swig/howto.test b/gr-howto-write-a-block/swig/howto.test
new file mode 100644
index 000000000..ffe7251cd
--- /dev/null
+++ b/gr-howto-write-a-block/swig/howto.test
@@ -0,0 +1,69 @@
+;;; -*- Scheme -*-
+;;;
+;;; Copyright 2010 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, see <http://www.gnu.org/licenses/>.
+;;;
+
+;;; If you're using Emacs's Scheme mode:
+;;; (put 'with-test-prefix 'scheme-indent-function 1)
+
+;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests.
+;;; See also the very end of the file, where the test-equal, test-eqv
+;;; and test-eq macros are defined.
+
+(define-module (test-module)
+ #:use-module (oop goops)
+ #:use-module (gnuradio core)
+ #:use-module (gnuradio test-suite lib)
+ #:duplicates (merge-generics replace check))
+
+
+;; Use our module
+(use-modules (gnuradio howto))
+
+
+(define (vector-map f v)
+ (list->vector (map f (vector->list v))))
+
+
+(with-test-prefix "square-ff"
+ (let* ((src-data #(-3. 4. -5.5 2. 3.))
+ (expected-result (vector-map (lambda (x) (* x x)) src-data))
+ (tb (gr:top-block-swig "QA top block"))
+ (src (gr:vector-source-f src-data #f))
+ (op (gr:howto-square-ff))
+ (dst (gr:vector-sink-f)))
+
+ (gr:connect tb src op dst)
+
+ (gr:run tb)
+ (test-equal expected-result (gr:data dst))))
+
+
+(with-test-prefix "square2-ff"
+ (let* ((src-data #(-3. 4. -5.5 2. 3.))
+ (expected-result (vector-map (lambda (x) (* x x)) src-data))
+ (tb (gr:top-block-swig "QA top block"))
+ (src (gr:vector-source-f src-data #f))
+ (op (gr:howto-square2-ff))
+ (dst (gr:vector-sink-f)))
+
+ (gr:connect tb src op dst)
+
+ (gr:run tb)
+ (test-equal expected-result (gr:data dst))))
+