
Raymond Toy pushed to branch issue-401-file-position-setter-wrong at cmucl / cmucl Commits: a2c10e79 by Raymond Toy at 2025-05-08T08:18:42-07:00 Add another file-position test As mentioned in the comment for fd-stream-file-position, we have added a test for the case where the input buffer doesn't have enough octets to form a complete character. We create a file consisting of a single character followed by 128 characters that require 4 octets for utf-8 encoding. Hence the in-buffer (of length 512) only has a partial utf-8 character at the end. - - - - - 1 changed file: - tests/fd-streams.lisp Changes: ===================================== tests/fd-streams.lisp ===================================== @@ -65,3 +65,28 @@ (read-line s) (assert-true (file-position s 0)) (assert-equal (file-position s) 0)))) + +(define-test file-position.3 + (:tag :issues) + ;; Create a test file just longer than the internal in-buffer + ;; length. This tests the case where the in-buffer does not have + ;; enough octets to form a complete character. (See comment in + ;; fd-stream-file-position. + (let ((test-file (merge-pathnames #p"file-pos.txt" *test-path*))) + (with-open-file (s test-file + :external-format :utf-8 + :direction :output + :if-exists :supersede) + (write-char #\a s) + ;; STR is a string consisting of the single codepoint #x11000 + ;; which is 4 octets when encoded using utf-8. + (let ((str (lisp::codepoints-string '(#x11000)))) + (dotimes (k 128) + (write-string str s))) + (write-char #\newline s) + (write-string "zzzzz" s) + (write-char #\newline s)) + (with-open-file (s test-file :external-format :utf-8) + (read-line s) + (assert-true (file-position s 0)) + (assert-equal (file-position s) 0)))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a2c10e79c31425b24cdea49c... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/a2c10e79c31425b24cdea49c... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)