source: trunk/source/tests/ansi-tests/file-string-length.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: 1.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Jan 22 21:34:04 2004
4;;;; Contains: Tests of FILE-STRING-LENGTH
5
6(in-package :cl-test)
7
8(deftest file-string-length.1
9  (with-open-file
10    (s "tmp.dat" :direction :output
11       :if-exists :supersede)
12    (loop for x across +standard-chars+
13          for len = (file-string-length s x)
14          do (assert (typep len '(or null (integer 0))))
15          do (let ((pos1 (file-position s)))
16               (write-char x s)
17               (let ((pos2 (file-position s)))
18                 (when (and pos1 pos2 len)
19                   (assert (= (+ pos1 len) pos2)))))))
20  nil)
21
22(deftest file-string-length.2
23  (with-open-file
24    (s "tmp.dat" :direction :output
25       :if-exists :supersede)
26    (loop for x across +standard-chars+
27          for len = (file-string-length s (string x))
28          do (assert (typep len '(or null (integer 0))))
29          do (let ((pos1 (file-position s)))
30               (write-sequence (string x) s)
31               (let ((pos2 (file-position s)))
32                 (when (and pos1 pos2 len)
33                   (assert (= (+ pos1 len) pos2)))))))
34  nil)
35
36(deftest file-string-length.3
37  (with-open-file
38   (stream "tmp.dat" :direction :output
39           :if-exists :supersede)
40   (let* ((s1 "abcde")
41          (n (file-string-length stream s1)))
42     (do-special-strings
43      (s2 s1 nil)
44      (assert (= (file-string-length stream s2) n)))))
45  nil)
46
47;;; Error tests
48
49(deftest file-string-length.error.1
50  (signals-error (file-string-length) program-error)
51  t)
52
53(deftest file-string-length.error.2
54  (signals-error
55   (with-open-file
56    (s "tmp.dat" :direction :output
57       :if-exists :supersede)
58    (file-string-length s))
59   program-error)
60  t)
61
62(deftest file-string-length.error.3
63  (signals-error
64   (with-open-file
65    (s "tmp.dat" :direction :output
66       :if-exists :supersede)
67    (file-string-length s #\x nil))
68   program-error)
69  t)
70
71
72 
73
Note: See TracBrowser for help on using the repository browser.