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

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

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

File size: 2.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Feb 14 18:36:48 2004
4;;;; Contains: Tests for MAKE-STRING-INPUT-STREAM
5
6(in-package :cl-test)
7
8(deftest make-string-input-stream.1
9  (let ((s (make-string-input-stream "")))
10    (values
11     (notnot (typep s 'stream))
12     (notnot (streamp s))
13     (notnot (input-stream-p s))
14     (output-stream-p s)))
15  t t t nil)
16
17(deftest make-string-input-stream.2
18  (let ((s (make-string-input-stream "abcd")))
19    (values
20     (notnot (typep s 'stream))
21     (notnot (streamp s))
22     (notnot (input-stream-p s))
23     (output-stream-p s)))
24  t t t nil)
25
26
27(deftest make-string-input-stream.3
28  (let ((s (make-string-input-stream "abcd" 1)))
29    (values (read-line s)))
30  "bcd")
31
32
33(deftest make-string-input-stream.4
34  (let ((s (make-string-input-stream "abcd" 0 2)))
35    (values (read-line s)))
36  "ab")
37
38(deftest make-string-input-stream.5
39  (let ((s (make-string-input-stream "abcd" 1 nil)))
40    (values (read-line s)))
41  "bcd")
42
43(deftest make-string-input-stream.6
44  (let ((str1 (make-array 6 :element-type 'character
45                          :initial-contents "abcdef"
46                          :fill-pointer 4)))
47    (let ((s (make-string-input-stream str1)))
48      (values (read-line s) (read-char s nil :eof))))
49  "abcd" :eof)
50
51(deftest make-string-input-stream.7
52  (let* ((str1 (make-array 6 :element-type 'character
53                           :initial-contents "abcdef"))
54         (str2 (make-array 4 :element-type 'character
55                           :displaced-to str1)))
56    (let ((s (make-string-input-stream str2)))
57      (values (read-line s) (read-char s nil :eof))))
58  "abcd" :eof)
59
60(deftest make-string-input-stream.8
61  (let* ((str1 (make-array 6 :element-type 'character
62                           :initial-contents "abcdef"))
63         (str2 (make-array 4 :element-type 'character
64                           :displaced-to str1
65                           :displaced-index-offset 1)))
66    (let ((s (make-string-input-stream str2)))
67      (values (read-line s) (read-char s nil :eof))))
68  "bcde" :eof)
69
70(deftest make-string-input-stream.9
71  (let ((str1 (make-array 6 :element-type 'character
72                          :initial-contents "abcdef"
73                          :adjustable t)))
74    (let ((s (make-string-input-stream str1)))
75      (values (read-line s) (read-char s nil :eof))))
76  "abcdef" :eof)
77
78(deftest make-string-input-stream.10
79  :notes (:allow-nil-arrays :nil-vectors-are-strings)
80  (let ((s (make-string-input-stream
81            (make-array 0 :element-type nil))))
82    (read-char s nil :eof))
83  :eof)
84
85;;; Error tests
86
87(deftest make-string-input-stream.error.1
88  (signals-error (make-string-input-stream) program-error)
89  t)
90
91(deftest make-string-input-stream.error.2
92  (signals-error (make-string-input-stream "abc" 1 2 nil) program-error)
93  t)
Note: See TracBrowser for help on using the repository browser.