write-char.lsp 1 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Jan 18 20:50:31 2004
;;;; Contains: Tests of WRITE-CHAR

(in-package :cl-test)

(deftest write-char.1
  (loop for i from 0 to 255
sds's avatar
sds committed
10 11 12 13 14 15 16
        for c = (code-char i)
        when c
        unless (string= (with-output-to-string
                          (*standard-output*)
                          (write-char c))
                        (string c))
        collect c)
17 18
  nil)

19
(deftest write-char.2
pfdietz's avatar
pfdietz committed
20 21 22 23 24 25 26
  (with-input-from-string
   (is "abcd")
   (with-output-to-string
     (os)
     (let ((*terminal-io* (make-two-way-stream is os)))
       (write-char #\$ t)
       (close *terminal-io*))))
27 28 29 30 31 32 33 34
  "$")

(deftest write-char.3
  (with-output-to-string
    (*standard-output*)
    (write-char #\: nil))
  ":")

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
;;; Error tests

(deftest write-char.error.1
  (signals-error (write-char) program-error)
  t)

(deftest write-char.error.2
  (signals-error
   (with-output-to-string
     (s)
     (write-char #\a s nil))
   program-error)
  t)

;;; More tests in other files