diff options
Diffstat (limited to 'gnuradio-core/src/guile/qa_0000_basics.scm')
-rw-r--r-- | gnuradio-core/src/guile/qa_0000_basics.scm | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/gnuradio-core/src/guile/qa_0000_basics.scm b/gnuradio-core/src/guile/qa_0000_basics.scm new file mode 100644 index 000000000..19bde0589 --- /dev/null +++ b/gnuradio-core/src/guile/qa_0000_basics.scm @@ -0,0 +1,82 @@ +(use-modules (gnuradio core)) +(use-modules (oop goops)) + +(load-from-path "srfi/srfi-64") +(use-modules (ice-9 format)) +(use-modules (ice-9 pretty-print)) + +;; (write "Hello QA world!\n") + +(define (vector-map f v) + (list->vector (map f (vector->list v)))) + +(define (test-1) + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "my top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using gr:ep to create endpoints + (gr:connect tb (gr:ep src 0) (gr:ep op 0)) + (gr:connect tb (gr:ep op 0) (gr:ep dst 0)) + + (gr:run tb) + (let ((actual-result (gr:data dst))) + (test-equal expected-result actual-result)))) + +(define (test-2) + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "my top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using just blocks + (gr:connect tb src op) + (gr:connect tb op dst) + + (gr:run tb) + (let ((actual-result (gr:data dst))) + (test-equal expected-result actual-result)))) + +(define (test-3) + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "my top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using lists to represent endpoints + (gr:connect tb `(,src 0) `(,op 0)) + (gr:connect tb `(,op 0) `(,dst 0)) + + (gr:run tb) + (let ((actual-result (gr:data dst))) + (test-equal expected-result actual-result)))) + +(define (test-4) + (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5)) + (expected-result (vector-map (lambda (x) (* x 2)) src-data)) + (tb (gr:top-block-swig "my top block")) + (src (gr:vector-source-i src-data #f)) + (op (gr:multiply-const-ii 2)) + (dst (gr:vector-sink-i))) + + ;; using multiple endpoints + (gr:connect tb src op dst) + + (gr:run tb) + (let ((actual-result (gr:data dst))) + (test-equal expected-result actual-result)))) + + +(test-begin "qa_0000_basics") +(test-1) +(test-2) +(test-3) +(test-4) +(test-end "qa_0000_basics") |