@@ -141,6 +141,8 @@ mktemp() do path, io
141
141
write (io, s)
142
142
end
143
143
144
+ nc = ncodeunits (first (s, 90 ))
145
+
144
146
@test String (read (path, enc " ISO-2022-JP" )) == s
145
147
@test String (open (io-> read (io, enc " ISO-2022-JP" ), path)) == s
146
148
@test String (open (io-> read (io), path, enc " ISO-2022-JP" )) == s
@@ -149,14 +151,48 @@ mktemp() do path, io
149
151
@test String (open (io-> read (io, 1000 , enc " ISO-2022-JP" ), path)) == s
150
152
@test String (open (io-> read (io, 1000 ), path, enc " ISO-2022-JP" )) == s
151
153
152
- @test String (read (path, 10 , enc " ISO-2022-JP" )) == first (s, 10 )
153
- @test String (open (io-> read (io, 10 , enc " ISO-2022-JP" ), path)) == first (s, 10 )
154
- @test String (open (io-> read (io, 10 ), path, enc " ISO-2022-JP" )) == first (s, 10 )
154
+ @test String (read (path, nc , enc " ISO-2022-JP" )) == first (s, nc )
155
+ @test String (open (io-> read (io, nc , enc " ISO-2022-JP" ), path)) == first (s, nc )
156
+ @test String (open (io-> read (io, nc ), path, enc " ISO-2022-JP" )) == first (s, nc )
155
157
156
158
@test read (path, String, enc " ISO-2022-JP" ) == s
157
159
@test open (io-> read (io, String, enc " ISO-2022-JP" ), path) == s
158
160
@test open (io-> read (io, String), path, enc " ISO-2022-JP" ) == s
159
161
162
+ b = zeros (UInt8, nc)
163
+ @test open (io-> read! (io, b), path, enc " ISO-2022-JP" ) === b
164
+ @test String (b) == first (s, 90 )
165
+
166
+ b = zeros (UInt8, nc)
167
+ @test open (io-> readbytes! (io, b), path, enc " ISO-2022-JP" ) == ncodeunits (s)
168
+ @test String (b) == s
169
+
170
+ b = zeros (UInt8, 1000 )
171
+ @test open (io-> readbytes! (io, b), path, enc " ISO-2022-JP" ) == ncodeunits (s)
172
+ @test length (b) == 1000
173
+ @test String (b[1 : ncodeunits (s)]) == s
174
+
175
+ b = UInt8[]
176
+ @test open (io-> readbytes! (io, b), path, enc " ISO-2022-JP" ) == 0
177
+ @test length (b) == 0
178
+
179
+ b = zeros (UInt8, nc)
180
+ @test open (io-> readbytes! (io, b, nc), path, enc " ISO-2022-JP" ) == nc
181
+ @test String (b) == first (s, 90 )
182
+
183
+ b = zeros (UInt8, 1000 )
184
+ @test open (io-> readbytes! (io, b, nc), path, enc " ISO-2022-JP" ) == nc
185
+ @test length (b) == 1000
186
+ @test String (b[1 : nc]) == first (s, 90 )
187
+
188
+ b = UInt8[]
189
+ @test open (io-> readbytes! (io, b, nc), path, enc " ISO-2022-JP" ) == nc
190
+ @test String (b) == first (s, 90 )
191
+
192
+ b = UInt8[]
193
+ open (io-> while ! eof (io); push! (b, read (io, UInt8)) end , path, enc " ISO-2022-JP" )
194
+ @test String (b) == s
195
+
160
196
@test readuntil (path, enc " ISO-2022-JP" , ' \0 ' ) == " a string "
161
197
@test open (io-> readuntil (io, enc " ISO-2022-JP" , ' \0 ' ), path) == " a string "
162
198
@test open (io-> readuntil (io, enc " ISO-2022-JP" , ' \0 ' , keep= true ), path) == " a string \0 "
0 commit comments