summaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2018-10-14 02:22:22 -0400
committerMark H Weaver <mhw@netris.org>2018-10-14 02:27:23 -0400
commitfe73fedab40cf716cc39139a61c078e2c9a2f37f (patch)
tree9cc44d2d859ba8c3c75d38ad37397d81034f1cec /test-suite
parentb44f505f1571fc9c42e58982f161a9cfc81fb7f4 (diff)
Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>. Reported by Josh Datko <jbd@cryptotronix.com>. * libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN) (SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to validate the result of 'scm_ilength' after it has been stored in the user variable 'cvar'. * test-suite/tests/bytevectors.test: Add tests. Use '#:use-module' instead of ':use-module' in 'define-module' form.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/bytevectors.test37
1 files changed, 32 insertions, 5 deletions
diff --git a/test-suite/tests/bytevectors.test b/test-suite/tests/bytevectors.test
index f0d9f1983..5d4568d82 100644
--- a/test-suite/tests/bytevectors.test
+++ b/test-suite/tests/bytevectors.test
@@ -1,6 +1,6 @@
;;;; bytevectors.test --- R6RS bytevectors. -*- mode: scheme; coding: utf-8; -*-
;;;;
-;;;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc.
;;;;
;;;; Ludovic Courtès
;;;;
@@ -19,10 +19,11 @@
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (test-bytevector)
- :use-module (test-suite lib)
- :use-module (system base compile)
- :use-module (rnrs bytevectors)
- :use-module (srfi srfi-4))
+ #:use-module (test-suite lib)
+ #:use-module (system base compile)
+ #:use-module (rnrs bytevectors)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-4))
(define exception:decoding-error
(cons 'decoding-error "input (locale conversion|decoding) error"))
@@ -111,6 +112,14 @@
(equal? lst
(bytevector->u8-list (u8-list->bytevector lst)))))
+ (pass-if-exception "u8-list->bytevector [invalid argument type]"
+ exception:wrong-type-arg
+ (u8-list->bytevector 'not-a-list))
+
+ (pass-if-exception "u8-list->bytevector [circular list]"
+ exception:wrong-type-arg
+ (u8-list->bytevector (circular-list 1 2 3)))
+
(pass-if "bytevector-uint-{ref,set!} [small]"
(let ((b (make-bytevector 15)))
(bytevector-uint-set! b 0 #x1234
@@ -206,6 +215,24 @@
(bytevector-u8-set! bv 3 #xff)
bv)))
+ (pass-if-exception "sint-list->bytevector [invalid argument type]"
+ exception:wrong-type-arg
+ (sint-list->bytevector 'not-a-list (endianness big) 2))
+
+ (pass-if-exception "uint-list->bytevector [invalid argument type]"
+ exception:wrong-type-arg
+ (uint-list->bytevector 'not-a-list (endianness big) 2))
+
+ (pass-if-exception "sint-list->bytevector [circular list]"
+ exception:wrong-type-arg
+ (sint-list->bytevector (circular-list 1 2 3) (endianness big)
+ 2))
+
+ (pass-if-exception "uint-list->bytevector [circular list]"
+ exception:wrong-type-arg
+ (uint-list->bytevector (circular-list 1 2 3) (endianness big)
+ 2))
+
(pass-if-exception "sint-list->bytevector [out-of-range]"
exception:out-of-range
(sint-list->bytevector (list 0 0 (expt 2 16)) (endianness big)