;;;; srfi-4.test --- Test suite for Guile's SRFI-4 functions. -*- scheme -*- ;;;; Martin Grabmueller, 2001-06-26 ;;;; ;;;; Copyright (C) 2001, 2006, 2010 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public ;;;; License as published by the Free Software Foundation; either ;;;; version 3 of the License, or (at your option) any later version. ;;;; ;;;; This library 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 ;;;; Lesser General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Lesser General Public ;;;; License along with this library; if not, write to the Free Software ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA (use-modules (srfi srfi-4) (test-suite lib)) (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))))) (pass-if "u8vector->list/uniform-vector->list" (equal? (u8vector->list (u8vector 1 2 3 4)) (uniform-vector->list (u8vector 1 2 3 4)))) (pass-if "make-u8vector" (equal? (list->u8vector '(7 7 7 7)) (make-u8vector 4 7)))) (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))))) (pass-if "s8vector->list/uniform-vector->list" (equal? (s8vector->list (s8vector 1 2 3 4)) (uniform-vector->list (s8vector 1 2 3 4)))) (pass-if "make-s8vector" (equal? (list->s8vector '(7 7 7 7)) (make-s8vector 4 7)))) (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))))) (pass-if "u16vector->list/uniform-vector->list" (equal? (u16vector->list (u16vector 1 2 3 4)) (uniform-vector->list (u16vector 1 2 3 4)))) (pass-if "make-u16vector" (equal? (list->u16vector '(7 7 7 7)) (make-u16vector 4 7)))) (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))))) (pass-if "s16vector->list/uniform-vector->list" (equal? (s16vector->list (s16vector 1 2 3 4)) (uniform-vector->list (s16vector 1 2 3 4)))) (pass-if "make-s16vector" (equal? (list->s16vector '(7 7 7 7)) (make-s16vector 4 7)))) (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))))) (pass-if "u32vector->list/uniform-vector->list" (equal? (u32vector->list (u32vector 1 2 3 4)) (uniform-vector->list (u32vector 1 2 3 4)))) (pass-if "make-u32vector" (equal? (list->u32vector '(7 7 7 7)) (make-u32vector 4 7)))) (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))))) (pass-if "s32vector->list/uniform-vector->list" (equal? (s32vector->list (s32vector 1 2 3 4)) (uniform-vector->list (s32vector 1 2 3 4)))) (pass-if "make-s32vector" (equal? (list->s32vector '(7 7 7 7)) (make-s32vector 4 7)))) (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))))) (pass-if "u64vector->list/uniform-vector->list" (equal? (u64vector->list (u64vector 1 2 3 4)) (uniform-vector->list (u64vector 1 2 3 4)))) (pass-if "make-u64vector" (equal? (list->u64vector '(7 7 7 7)) (make-u64vector 4 7)))) (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))))) (pass-if "s64vector->list/uniform-vector->list" (equal? (s64vector->list (s64vector 1 2 3 4)) (uniform-vector->list (s64vector 1 2 3 4)))) (pass-if "make-s64vector" (equal? (list->s64vector '(7 7 7 7)) (make-s64vector 4 7)))) (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))))) (pass-if "f32vector->list/uniform-vector->list" (equal? (f32vector->list (f32vector 1 2 3 4)) (uniform-vector->list (f32vector 1 2 3 4)))) (pass-if "make-f32vector" (equal? (list->f32vector '(7 7 7 7)) (make-f32vector 4 7)))) (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))))) (pass-if "f64vector->list/uniform-vector->list" (equal? (f64vector->list (f64vector 1 2 3 4)) (uniform-vector->list (f64vector 1 2 3 4)))) (pass-if "make-f64vector" (equal? (list->f64vector '(7 7 7 7)) (make-f64vector 4 7))))