source: trunk/source/tests/ansi-tests/make-broadcast-stream.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Jan 29 21:28:25 2004
4;;;; Contains: Tests of MAKE-BROADCAST-STREAM
5
6(in-package :cl-test)
7
8(deftest make-broadcast-stream.1
9  (let ((s (make-broadcast-stream)))
10    (assert (typep s 'stream))
11    (assert (typep s 'broadcast-stream))
12    (assert (output-stream-p s))
13    ;; (assert (not (input-stream-p s)))
14    (assert (open-stream-p s))
15    (assert (streamp s))
16    ;; (assert (eq (stream-element-type s) t))
17    (values
18     (notnot (typep s 'stream))
19     (notnot (typep s 'broadcast-stream))
20     (notnot (output-stream-p s))
21     (progn (write-char #\x s) nil)
22     ))
23  t t t nil)
24
25(deftest make-broadcast-stream.2
26  (with-output-to-string
27    (s1)
28    (let ((s (make-broadcast-stream s1)))
29      (assert (typep s 'stream))
30      (assert (typep s 'broadcast-stream))
31      (assert (output-stream-p s))
32      ;; (assert (not (input-stream-p s)))
33      (assert (open-stream-p s))
34      (assert (streamp s))
35      (assert (eql (stream-element-type s)
36                   (stream-element-type s1)))
37      (write-char #\x s)))
38  "x")
39
40(deftest make-broadcast-stream.3
41  (let ((s1 (make-string-output-stream))
42        (s2 (make-string-output-stream)))
43    (let ((s (make-broadcast-stream s1 s2)))
44      (assert (typep s 'stream))
45      (assert (typep s 'broadcast-stream))
46      (assert (output-stream-p s))
47      ;; (assert (not (input-stream-p s)))
48      (assert (open-stream-p s))
49      (assert (streamp s))
50      (assert (eql (stream-element-type s)
51                   (stream-element-type s2)))
52      (format s "This is a test"))
53    (values
54     (get-output-stream-string s1)
55     (get-output-stream-string s2)))
56  "This is a test"
57  "This is a test")
58
59(deftest make-broadcast-stream.4
60  (fresh-line (make-broadcast-stream))
61  nil)
62
63(deftest make-broadcast-stream.5
64  (file-length (make-broadcast-stream))
65  0)
66
67(deftest make-broadcast-stream.6
68  (file-position (make-broadcast-stream))
69  0)
70
71(deftest make-broadcast-stream.7
72  (file-string-length (make-broadcast-stream) "antidisestablishmentarianism")
73  1)
74
75(deftest make-broadcast-stream.8
76  (stream-external-format (make-broadcast-stream))
77  :default)
78
79
80
81;;; FIXME
82;;; Add tests for: close,
83;;;  peek-char, read-char-no-hang, terpri, fresh-line, unread-char,
84;;;  read-line, write-line, write-string, read-sequence, write-sequence,
85;;;  read-byte, write-byte, listen, clear-input, finish-output, force-output,
86;;;  clear-output, print, prin1 princ
87
88;;; Error tests
89
90(deftest make-broadcast-stream.error.1
91  (check-type-error #'make-broadcast-stream
92                    #'(lambda (x) (and (streamp x) (output-stream-p x))))
93  nil)
94
95(deftest make-broadcast-stream.error.2
96  (check-type-error #'make-broadcast-stream
97                    #'(lambda (x) (and (streamp x) (output-stream-p x)))
98                    *streams*)
99  nil)
Note: See TracBrowser for help on using the repository browser.