@@ -115,42 +115,44 @@ function is_stats_consistent(stream)
115
115
true
116
116
end
117
117
118
- @check function read_byte_data (
119
- kws= read_codecs_kws,
120
- data= datas,
121
- )
122
- stream = wrap_stream (kws, IOBuffer (data))
123
- for i in 1 : length (data)
124
- position (stream) == i- 1 || return false
118
+ @testset " read" begin
119
+ @check function read_byte_data (
120
+ kws= read_codecs_kws,
121
+ data= datas,
122
+ )
123
+ stream = wrap_stream (kws, IOBuffer (data))
124
+ for i in 1 : length (data)
125
+ position (stream) == i- 1 || return false
126
+ is_stats_consistent (stream) || return false
127
+ read (stream, UInt8) == data[i] || return false
128
+ end
125
129
is_stats_consistent (stream) || return false
126
- read (stream, UInt8) == data[i] || return false
130
+ eof (stream)
127
131
end
128
- is_stats_consistent (stream) || return false
129
- eof (stream)
130
- end
131
- @check function read_data (
132
- kws = read_codecs_kws,
133
- data = datas,
134
- )
135
- stream = wrap_stream (kws, IOBuffer (data) )
136
- read (stream) == data || return false
137
- is_stats_consistent (stream) || return false
138
- eof (stream)
139
- end
140
- @check function read_data_methods (
141
- kws = read_codecs_kws,
142
- data = datas,
143
- rs = Data . Vectors (read_methods),
144
- )
145
- stream = wrap_stream (kws, IOBuffer (data) )
146
- x = UInt8[]
147
- for r in rs
148
- d = r (stream)
149
- append! (x, d)
150
- length (x) == position (stream) || return false
132
+ @check function read_data (
133
+ kws = read_codecs_kws,
134
+ data = datas,
135
+ )
136
+ stream = wrap_stream (kws, IOBuffer (data))
137
+ read (stream) == data || return false
138
+ is_stats_consistent (stream) || return false
139
+ eof (stream )
140
+ end
141
+ @check function read_data_methods (
142
+ kws = read_codecs_kws,
143
+ data = datas,
144
+ rs = Data . Vectors (read_methods),
145
+ )
146
+ stream = wrap_stream (kws, IOBuffer (data))
147
+ x = UInt8[]
148
+ for r in rs
149
+ d = r (stream )
150
+ append! (x, d)
151
+ length (x) == position (stream) || return false
152
+ end
153
+ is_stats_consistent (stream) || return false
154
+ x == data[ eachindex (x)]
151
155
end
152
- is_stats_consistent (stream) || return false
153
- x == data[eachindex (x)]
154
156
end
155
157
156
158
# flush all nested streams and return final data
@@ -167,27 +169,29 @@ end
167
169
168
170
const write_codecs_kws = map (reverse, read_codecs_kws)
169
171
170
- @check function write_data (
171
- kws= write_codecs_kws,
172
- data= datas,
173
- )
174
- stream = wrap_stream (kws, IOBuffer ())
175
- write (stream, data) == length (data) || return false
176
- take_all (stream) == data || return false
177
- is_stats_consistent (stream) || return false
178
- true
179
- end
180
- @check function write_byte_data (
181
- kws= write_codecs_kws,
182
- data= datas,
183
- )
184
- stream = wrap_stream (kws, IOBuffer ())
185
- for i in 1 : length (data)
186
- position (stream) == i- 1 || return false
172
+ @testset " write" begin
173
+ @check function write_data (
174
+ kws= write_codecs_kws,
175
+ data= datas,
176
+ )
177
+ stream = wrap_stream (kws, IOBuffer ())
178
+ write (stream, data) == length (data) || return false
179
+ take_all (stream) == data || return false
187
180
is_stats_consistent (stream) || return false
188
- write (stream, data[i]) == 1 || return false
181
+ true
182
+ end
183
+ @check function write_byte_data (
184
+ kws= write_codecs_kws,
185
+ data= datas,
186
+ )
187
+ stream = wrap_stream (kws, IOBuffer ())
188
+ for i in 1 : length (data)
189
+ position (stream) == i- 1 || return false
190
+ is_stats_consistent (stream) || return false
191
+ write (stream, data[i]) == 1 || return false
192
+ end
193
+ take_all (stream) == data || return false
194
+ is_stats_consistent (stream) || return false
195
+ true
189
196
end
190
- take_all (stream) == data || return false
191
- is_stats_consistent (stream) || return false
192
- true
193
197
end
0 commit comments