summaryrefslogtreecommitdiff
path: root/test-suite/tests/srfi-4.test
diff options
context:
space:
mode:
authorMartin Grabmüller <mgrabmue@cs.tu-berlin.de>2001-06-27 13:17:12 +0000
committerMartin Grabmüller <mgrabmue@cs.tu-berlin.de>2001-06-27 13:17:12 +0000
commit39cb0b041d27f88aa76f51df20f632674320ec62 (patch)
treea710e397275312d6d3b74e0c40703e7b2fee420b /test-suite/tests/srfi-4.test
parentb858464a0a34381caf8661ec32a27bb94ce8c6cc (diff)
downloadguile-39cb0b041d27f88aa76f51df20f632674320ec62.tar.gz
* tests/srfi-4.test: New file.
Diffstat (limited to 'test-suite/tests/srfi-4.test')
-rw-r--r--test-suite/tests/srfi-4.test312
1 files changed, 312 insertions, 0 deletions
diff --git a/test-suite/tests/srfi-4.test b/test-suite/tests/srfi-4.test
new file mode 100644
index 000000000..ac6ce3792
--- /dev/null
+++ b/test-suite/tests/srfi-4.test
@@ -0,0 +1,312 @@
+;;;; srfi-4.test --- Test suite for Guile's SRFI-4 functions. -*- scheme -*-
+;;;; Martin Grabmueller, 2001-06-26
+;;;;
+;;;; Copyright (C) 2001 Free Software Foundation, Inc.
+;;;;
+;;;; This program 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 2, or (at your option)
+;;;; any later version.
+;;;;
+;;;; This program 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 software; see the file COPYING. If not, write to
+;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+;;;; Boston, MA 02111-1307 USA
+
+(use-modules (srfi srfi-4))
+
+(with-test-prefix "u8 vectors"
+
+ (pass-if "u8vector? success"
+ (u8vector? (u8vector)))
+
+ (pass-if "u8vector? failure"
+ (not (u8vector? (s8vector))))
+
+ (pass-if "u8vector-length success 1"
+ (= (u8vector-length (u8vector)) 0))
+
+ (pass-if "u8vector-length success 2"
+ (= (u8vector-length (u8vector 3)) 1))
+
+ (pass-if "u8vector-length failure"
+ (not (= (u8vector-length (u8vector 3)) 3)))
+
+ (pass-if "u8vector-ref"
+ (= (u8vector-ref (u8vector 1 2 3) 1) 2))
+
+ (pass-if "u8vector-set!/ref"
+ (= (let ((s (make-u8vector 10 0)))
+ (u8vector-set! s 4 33)
+ (u8vector-ref s 4)) 33))
+
+ (pass-if "u8vector->list/list->u8vector"
+ (equal? (u8vector->list (u8vector 1 2 3 4))
+ (u8vector->list (list->u8vector '(1 2 3 4))))))
+
+(with-test-prefix "s8 vectors"
+
+ (pass-if "s8vector? success"
+ (s8vector? (s8vector)))
+
+ (pass-if "s8vector? failure"
+ (not (s8vector? (u8vector))))
+
+ (pass-if "s8vector-length success 1"
+ (= (s8vector-length (s8vector)) 0))
+
+ (pass-if "s8vector-length success 2"
+ (= (s8vector-length (s8vector -3)) 1))
+
+ (pass-if "s8vector-length failure"
+ (not (= (s8vector-length (s8vector 3)) 3)))
+
+ (pass-if "s8vector-ref"
+ (= (s8vector-ref (s8vector 1 2 3) 1) 2))
+
+ (pass-if "s8vector-set!/ref"
+ (= (let ((s (make-s8vector 10 0)))
+ (s8vector-set! s 4 33)
+ (s8vector-ref s 4)) 33))
+
+ (pass-if "s8vector->list/list->s8vector"
+ (equal? (s8vector->list (s8vector 1 2 3 4))
+ (s8vector->list (list->s8vector '(1 2 3 4))))))
+
+
+(with-test-prefix "u16 vectors"
+
+ (pass-if "u16vector? success"
+ (u16vector? (u16vector)))
+
+ (pass-if "u16vector? failure"
+ (not (u16vector? (s16vector))))
+
+ (pass-if "u16vector-length success 1"
+ (= (u16vector-length (u16vector)) 0))
+
+ (pass-if "u16vector-length success 2"
+ (= (u16vector-length (u16vector 3)) 1))
+
+ (pass-if "u16vector-length failure"
+ (not (= (u16vector-length (u16vector 3)) 3)))
+
+ (pass-if "u16vector-ref"
+ (= (u16vector-ref (u16vector 1 2 3) 1) 2))
+
+ (pass-if "u16vector-set!/ref"
+ (= (let ((s (make-u16vector 10 0)))
+ (u16vector-set! s 4 33)
+ (u16vector-ref s 4)) 33))
+
+ (pass-if "u16vector->list/list->u16vector"
+ (equal? (u16vector->list (u16vector 1 2 3 4))
+ (u16vector->list (list->u16vector '(1 2 3 4))))))
+
+(with-test-prefix "s16 vectors"
+
+ (pass-if "s16vector? success"
+ (s16vector? (s16vector)))
+
+ (pass-if "s16vector? failure"
+ (not (s16vector? (u16vector))))
+
+ (pass-if "s16vector-length success 1"
+ (= (s16vector-length (s16vector)) 0))
+
+ (pass-if "s16vector-length success 2"
+ (= (s16vector-length (s16vector -3)) 1))
+
+ (pass-if "s16vector-length failure"
+ (not (= (s16vector-length (s16vector 3)) 3)))
+
+ (pass-if "s16vector-ref"
+ (= (s16vector-ref (s16vector 1 2 3) 1) 2))
+
+ (pass-if "s16vector-set!/ref"
+ (= (let ((s (make-s16vector 10 0)))
+ (s16vector-set! s 4 33)
+ (s16vector-ref s 4)) 33))
+
+ (pass-if "s16vector->list/list->s16vector"
+ (equal? (s16vector->list (s16vector 1 2 3 4))
+ (s16vector->list (list->s16vector '(1 2 3 4))))))
+
+(with-test-prefix "u32 vectors"
+
+ (pass-if "u32vector? success"
+ (u32vector? (u32vector)))
+
+ (pass-if "u32vector? failure"
+ (not (u32vector? (s32vector))))
+
+ (pass-if "u32vector-length success 1"
+ (= (u32vector-length (u32vector)) 0))
+
+ (pass-if "u32vector-length success 2"
+ (= (u32vector-length (u32vector 3)) 1))
+
+ (pass-if "u32vector-length failure"
+ (not (= (u32vector-length (u32vector 3)) 3)))
+
+ (pass-if "u32vector-ref"
+ (= (u32vector-ref (u32vector 1 2 3) 1) 2))
+
+ (pass-if "u32vector-set!/ref"
+ (= (let ((s (make-u32vector 10 0)))
+ (u32vector-set! s 4 33)
+ (u32vector-ref s 4)) 33))
+
+ (pass-if "u32vector->list/list->u32vector"
+ (equal? (u32vector->list (u32vector 1 2 3 4))
+ (u32vector->list (list->u32vector '(1 2 3 4))))))
+
+(with-test-prefix "s32 vectors"
+
+ (pass-if "s32vector? success"
+ (s32vector? (s32vector)))
+
+ (pass-if "s32vector? failure"
+ (not (s32vector? (u32vector))))
+
+ (pass-if "s32vector-length success 1"
+ (= (s32vector-length (s32vector)) 0))
+
+ (pass-if "s32vector-length success 2"
+ (= (s32vector-length (s32vector -3)) 1))
+
+ (pass-if "s32vector-length failure"
+ (not (= (s32vector-length (s32vector 3)) 3)))
+
+ (pass-if "s32vector-ref"
+ (= (s32vector-ref (s32vector 1 2 3) 1) 2))
+
+ (pass-if "s32vector-set!/ref"
+ (= (let ((s (make-s32vector 10 0)))
+ (s32vector-set! s 4 33)
+ (s32vector-ref s 4)) 33))
+
+ (pass-if "s32vector->list/list->s32vector"
+ (equal? (s32vector->list (s32vector 1 2 3 4))
+ (s32vector->list (list->s32vector '(1 2 3 4))))))
+
+(with-test-prefix "u64 vectors"
+
+ (pass-if "u64vector? success"
+ (u64vector? (u64vector)))
+
+ (pass-if "u64vector? failure"
+ (not (u64vector? (s64vector))))
+
+ (pass-if "u64vector-length success 1"
+ (= (u64vector-length (u64vector)) 0))
+
+ (pass-if "u64vector-length success 2"
+ (= (u64vector-length (u64vector 3)) 1))
+
+ (pass-if "u64vector-length failure"
+ (not (= (u64vector-length (u64vector 3)) 3)))
+
+ (pass-if "u64vector-ref"
+ (= (u64vector-ref (u64vector 1 2 3) 1) 2))
+
+ (pass-if "u64vector-set!/ref"
+ (= (let ((s (make-u64vector 10 0)))
+ (u64vector-set! s 4 33)
+ (u64vector-ref s 4)) 33))
+
+ (pass-if "u64vector->list/list->u64vector"
+ (equal? (u64vector->list (u64vector 1 2 3 4))
+ (u64vector->list (list->u64vector '(1 2 3 4))))))
+
+(with-test-prefix "s64 vectors"
+
+ (pass-if "s64vector? success"
+ (s64vector? (s64vector)))
+
+ (pass-if "s64vector? failure"
+ (not (s64vector? (u64vector))))
+
+ (pass-if "s64vector-length success 1"
+ (= (s64vector-length (s64vector)) 0))
+
+ (pass-if "s64vector-length success 2"
+ (= (s64vector-length (s64vector -3)) 1))
+
+ (pass-if "s64vector-length failure"
+ (not (= (s64vector-length (s64vector 3)) 3)))
+
+ (pass-if "s64vector-ref"
+ (= (s64vector-ref (s64vector 1 2 3) 1) 2))
+
+ (pass-if "s64vector-set!/ref"
+ (= (let ((s (make-s64vector 10 0)))
+ (s64vector-set! s 4 33)
+ (s64vector-ref s 4)) 33))
+
+ (pass-if "s64vector->list/list->s64vector"
+ (equal? (s64vector->list (s64vector 1 2 3 4))
+ (s64vector->list (list->s64vector '(1 2 3 4))))))
+
+(with-test-prefix "f32 vectors"
+
+ (pass-if "f32vector? success"
+ (f32vector? (f32vector)))
+
+ (pass-if "f32vector? failure"
+ (not (f32vector? (s8vector))))
+
+ (pass-if "f32vector-length success 1"
+ (= (f32vector-length (f32vector)) 0))
+
+ (pass-if "f32vector-length success 2"
+ (= (f32vector-length (f32vector -3)) 1))
+
+ (pass-if "f32vector-length failure"
+ (not (= (f32vector-length (f32vector 3)) 3)))
+
+ (pass-if "f32vector-ref"
+ (= (f32vector-ref (f32vector 1 2 3) 1) 2))
+
+ (pass-if "f32vector-set!/ref"
+ (= (let ((s (make-f32vector 10 0)))
+ (f32vector-set! s 4 33)
+ (f32vector-ref s 4)) 33))
+
+ (pass-if "f32vector->list/list->f32vector"
+ (equal? (f32vector->list (f32vector 1 2 3 4))
+ (f32vector->list (list->f32vector '(1 2 3 4))))))
+
+(with-test-prefix "f64 vectors"
+
+ (pass-if "f64vector? success"
+ (f64vector? (f64vector)))
+
+ (pass-if "f64vector? failure"
+ (not (f64vector? (f32vector))))
+
+ (pass-if "f64vector-length success 1"
+ (= (f64vector-length (f64vector)) 0))
+
+ (pass-if "f64vector-length success 2"
+ (= (f64vector-length (f64vector -3)) 1))
+
+ (pass-if "f64vector-length failure"
+ (not (= (f64vector-length (f64vector 3)) 3)))
+
+ (pass-if "f64vector-ref"
+ (= (f64vector-ref (f64vector 1 2 3) 1) 2))
+
+ (pass-if "f64vector-set!/ref"
+ (= (let ((s (make-f64vector 10 0)))
+ (f64vector-set! s 4 33)
+ (f64vector-ref s 4)) 33))
+
+ (pass-if "f64vector->list/list->f64vector"
+ (equal? (f64vector->list (f64vector 1 2 3 4))
+ (f64vector->list (list->f64vector '(1 2 3 4))))))