Raymond Toy pushed to branch issue-401-file-position-setter-wrong at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • tests/fd-streams.lisp
    ... ... @@ -65,3 +65,28 @@
    65 65
           (read-line s)
    
    66 66
           (assert-true (file-position s 0))
    
    67 67
           (assert-equal (file-position s) 0))))
    
    68
    +
    
    69
    +(define-test file-position.3
    
    70
    +    (:tag :issues)
    
    71
    +  ;; Create a test file just longer than the internal in-buffer
    
    72
    +  ;; length.  This tests the case where the in-buffer does not have
    
    73
    +  ;; enough octets to form a complete character.  (See comment in
    
    74
    +  ;; fd-stream-file-position.
    
    75
    +  (let ((test-file (merge-pathnames #p"file-pos.txt" *test-path*)))
    
    76
    +    (with-open-file (s test-file
    
    77
    +		       :external-format :utf-8
    
    78
    +		       :direction :output
    
    79
    +		       :if-exists :supersede)
    
    80
    +      (write-char #\a s)
    
    81
    +      ;; STR is a string consisting of the single codepoint #x11000
    
    82
    +      ;; which is 4 octets when encoded using utf-8.
    
    83
    +      (let ((str (lisp::codepoints-string '(#x11000))))
    
    84
    +	(dotimes (k 128)
    
    85
    +	  (write-string str s)))
    
    86
    +      (write-char #\newline s)
    
    87
    +      (write-string "zzzzz" s)
    
    88
    +      (write-char #\newline s))
    
    89
    +    (with-open-file (s test-file :external-format :utf-8)
    
    90
    +      (read-line s)
    
    91
    +      (assert-true (file-position s 0))
    
    92
    +      (assert-equal (file-position s) 0))))