Raymond Toy pushed to branch issue-401-file-position-setter-wrong at cmucl / cmucl
Commits:
-
e7f7a9aa
by Raymond Toy at 2025-05-08T07:57:10-07:00
1 changed file:
Changes:
... | ... | @@ -34,3 +34,34 @@ |
34 | 34 | (setf s (open *test-file*))
|
35 | 35 | (file-length s))
|
36 | 36 | (delete-file *test-file*))))
|
37 | + |
|
38 | +(define-test file-position.1
|
|
39 | + (:tag :issues)
|
|
40 | + ;; Create a short test file
|
|
41 | + (let ((test-file (merge-pathnames #p"file-pos.txt" *test-path*)))
|
|
42 | + (with-open-file (s test-file
|
|
43 | + :direction :output
|
|
44 | + :if-exists :supersede)
|
|
45 | + (write-string "aaaaaa" s)
|
|
46 | + (write-char #\newline s))
|
|
47 | + (with-open-file (s test-file)
|
|
48 | + (read-line s)
|
|
49 | + (assert-true (file-position s 0))
|
|
50 | + (assert-equal (file-position s) 0))))
|
|
51 | + |
|
52 | +(define-test file-position.2
|
|
53 | + (:tag :issues)
|
|
54 | + ;; Create a test file just longer than the internal in-buffer length
|
|
55 | + ;; and the first line is more than 512 characters long.
|
|
56 | + (let ((test-file (merge-pathnames #p"file-pos.txt" *test-path*)))
|
|
57 | + (with-open-file (s test-file
|
|
58 | + :direction :output
|
|
59 | + :if-exists :supersede)
|
|
60 | + (write-string (make-string 512 :initial-element #\a) s)
|
|
61 | + (write-char #\newline s)
|
|
62 | + (write-string "zzzzz" s)
|
|
63 | + (write-char #\newline s))
|
|
64 | + (with-open-file (s test-file)
|
|
65 | + (read-line s)
|
|
66 | + (assert-true (file-position s 0))
|
|
67 | + (assert-equal (file-position s) 0)))) |