mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-06 02:40:26 -08:00
tests: add a test for failed conversion byte->char
Sometimes bytes are outside of the character range. In that case we should signal an error when we try to read them.
This commit is contained in:
parent
41f52d8d0f
commit
c33c8f2ef7
1 changed files with 19 additions and 3 deletions
|
|
@ -107,7 +107,8 @@
|
||||||
:initial-contents values
|
:initial-contents values
|
||||||
:fill-pointer 8))
|
:fill-pointer 8))
|
||||||
(stream (make-sequence-io-stream vector)))
|
(stream (make-sequence-io-stream vector)))
|
||||||
(test-byte-input-stream stream vector)))
|
(test-byte-input-stream stream vector)
|
||||||
|
(test-byte-output-stream stream 8)))
|
||||||
|
|
||||||
(deftest stream.smoke-read-char ()
|
(deftest stream.smoke-read-char ()
|
||||||
(let* ((values (map 'vector #'char-code "ABCDEFGHIJKLMNOP"))
|
(let* ((values (map 'vector #'char-code "ABCDEFGHIJKLMNOP"))
|
||||||
|
|
@ -115,7 +116,8 @@
|
||||||
:initial-contents values
|
:initial-contents values
|
||||||
:fill-pointer 8))
|
:fill-pointer 8))
|
||||||
(stream (make-sequence-io-stream vector :ascii)))
|
(stream (make-sequence-io-stream vector :ascii)))
|
||||||
(test-char-input-stream stream vector)))
|
(test-char-input-stream stream vector)
|
||||||
|
(test-char-output-stream stream 8)))
|
||||||
|
|
||||||
(deftest stream.smoke-bivalent ()
|
(deftest stream.smoke-bivalent ()
|
||||||
(let* ((values (map 'vector #'char-code "ABCDEFGHIJKLMNOP"))
|
(let* ((values (map 'vector #'char-code "ABCDEFGHIJKLMNOP"))
|
||||||
|
|
@ -123,7 +125,21 @@
|
||||||
:initial-contents values
|
:initial-contents values
|
||||||
:fill-pointer 8))
|
:fill-pointer 8))
|
||||||
(stream (make-sequence-io-stream vector :ascii)))
|
(stream (make-sequence-io-stream vector :ascii)))
|
||||||
(test-bivalent-input-stream stream vector)))
|
(test-bivalent-input-stream stream vector)
|
||||||
|
(test-bivalent-output-stream stream 8)))
|
||||||
|
|
||||||
|
;;; Ensure that we make a "clean" error (i.e not a segfault) when bivalent
|
||||||
|
;;; stream has bytes that can't be casted to characters.
|
||||||
|
(deftest stream.error-bivalent ()
|
||||||
|
(let* ((values (loop repeat 16 collect char-code-limit))
|
||||||
|
(vector (make-array 16 :element-type '(unsigned-byte 64)
|
||||||
|
:initial-contents values
|
||||||
|
:fill-pointer 8))
|
||||||
|
(stream (make-sequence-io-stream vector nil)))
|
||||||
|
(signals error (test-char-input-stream stream vector))
|
||||||
|
(finishes (test-byte-input-stream stream vector))
|
||||||
|
(finishes (test-char-output-stream stream 8))
|
||||||
|
(finishes (test-char-input-stream stream (subseq vector 8 16)))))
|
||||||
|
|
||||||
;;; Ensure that MAKE-SEQUENCE-INPUT-STREAM and MAKE-SEQUENCE-OUTPUT-STREAM can
|
;;; Ensure that MAKE-SEQUENCE-INPUT-STREAM and MAKE-SEQUENCE-OUTPUT-STREAM can
|
||||||
;;; take bytes that are larger than any character.
|
;;; take bytes that are larger than any character.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue