Lines Matching refs:stream
26 int ReadByte(Stream* stream, brillo::ErrorPtr* error) { in ReadByte() argument
28 return stream->ReadAllBlocking(&byte, sizeof(byte), error) ? byte : -1; in ReadByte()
206 StreamPtr stream = MemoryStream::OpenRef(buffer, sizeof(buffer), nullptr); in TEST() local
208 EXPECT_EQ(3, stream->GetSize()); in TEST()
209 EXPECT_EQ(5, ReadByte(stream.get(), nullptr)); in TEST()
210 EXPECT_EQ(2, ReadByte(stream.get(), nullptr)); in TEST()
211 EXPECT_EQ(3, ReadByte(stream.get(), nullptr)); in TEST()
213 EXPECT_EQ(-1, ReadByte(stream.get(), &error)); in TEST()
214 EXPECT_EQ(errors::stream::kPartialData, error->GetCode()); in TEST()
220 StreamPtr stream = MemoryStream::OpenCopyOf(buffer, sizeof(buffer), nullptr); in TEST() local
222 EXPECT_EQ(3, stream->GetSize()); in TEST()
223 EXPECT_EQ(1, ReadByte(stream.get(), nullptr)); in TEST()
224 EXPECT_EQ(2, ReadByte(stream.get(), nullptr)); in TEST()
225 EXPECT_EQ(3, ReadByte(stream.get(), nullptr)); in TEST()
227 EXPECT_EQ(-1, ReadByte(stream.get(), &error)); in TEST()
228 EXPECT_EQ(errors::stream::kPartialData, error->GetCode()); in TEST()
234 StreamPtr stream = MemoryStream::OpenRef(str, nullptr); in TEST() local
236 EXPECT_EQ(4, stream->GetSize()); in TEST()
237 EXPECT_EQ('A', ReadByte(stream.get(), nullptr)); in TEST()
238 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
239 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
240 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
241 EXPECT_EQ(-1, ReadByte(stream.get(), nullptr)); in TEST()
246 StreamPtr stream = MemoryStream::OpenCopyOf(str, nullptr); in TEST() local
248 EXPECT_EQ(4, stream->GetSize()); in TEST()
249 EXPECT_EQ('a', ReadByte(stream.get(), nullptr)); in TEST()
250 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
251 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
252 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
253 EXPECT_EQ(-1, ReadByte(stream.get(), nullptr)); in TEST()
258 StreamPtr stream = MemoryStream::OpenRef(str, nullptr); in TEST() local
260 EXPECT_EQ(4, stream->GetSize()); in TEST()
261 EXPECT_EQ('A', ReadByte(stream.get(), nullptr)); in TEST()
262 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
263 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
264 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
265 EXPECT_EQ(-1, ReadByte(stream.get(), nullptr)); in TEST()
270 StreamPtr stream = MemoryStream::OpenCopyOf(str, nullptr); in TEST() local
272 EXPECT_EQ(4, stream->GetSize()); in TEST()
273 EXPECT_EQ('a', ReadByte(stream.get(), nullptr)); in TEST()
274 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
275 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
276 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
277 EXPECT_EQ(-1, ReadByte(stream.get(), nullptr)); in TEST()
282 StreamPtr stream = MemoryStream::OpenRef(data, nullptr); in TEST() local
284 EXPECT_EQ(4, stream->GetSize()); in TEST()
285 EXPECT_EQ(0, stream->GetPosition()); in TEST()
286 EXPECT_EQ(4, stream->GetRemainingSize()); in TEST()
287 EXPECT_EQ('A', ReadByte(stream.get(), nullptr)); in TEST()
288 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
289 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
290 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
291 EXPECT_EQ(4, stream->GetPosition()); in TEST()
292 EXPECT_EQ(4, stream->GetSize()); in TEST()
293 EXPECT_EQ(0, stream->GetRemainingSize()); in TEST()
298 StreamPtr stream = MemoryStream::OpenCopyOf(data, nullptr); in TEST() local
300 EXPECT_EQ(4, stream->GetSize()); in TEST()
301 EXPECT_EQ(0, stream->GetPosition()); in TEST()
302 EXPECT_EQ(4, stream->GetRemainingSize()); in TEST()
303 EXPECT_EQ('a', ReadByte(stream.get(), nullptr)); in TEST()
304 EXPECT_EQ('b', ReadByte(stream.get(), nullptr)); in TEST()
305 EXPECT_EQ('c', ReadByte(stream.get(), nullptr)); in TEST()
306 EXPECT_EQ('d', ReadByte(stream.get(), nullptr)); in TEST()
307 EXPECT_EQ(4, stream->GetPosition()); in TEST()
308 EXPECT_EQ(4, stream->GetSize()); in TEST()
309 EXPECT_EQ(0, stream->GetRemainingSize()); in TEST()
314 StreamPtr stream = MemoryStream::CreateRef(&buffer, nullptr); in TEST() local
316 EXPECT_EQ(0, stream->GetPosition()); in TEST()
317 EXPECT_EQ(0, stream->GetSize()); in TEST()
318 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()
322 stream = MemoryStream::CreateRef(&buffer, nullptr); in TEST()
324 EXPECT_EQ(0, stream->GetPosition()); in TEST()
325 EXPECT_EQ(5, stream->GetSize()); in TEST()
326 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()
328 stream = MemoryStream::CreateRefForAppend(&buffer, nullptr); in TEST()
330 EXPECT_EQ(5, stream->GetPosition()); in TEST()
331 EXPECT_EQ(5, stream->GetSize()); in TEST()
332 EXPECT_TRUE(stream->WriteAllBlocking("abcde", 5, nullptr)); in TEST()
334 EXPECT_EQ(10, stream->GetPosition()); in TEST()
335 EXPECT_EQ(10, stream->GetSize()); in TEST()
336 EXPECT_TRUE(stream->SetPosition(0, nullptr)); in TEST()
337 EXPECT_EQ(0, stream->GetPosition()); in TEST()
338 EXPECT_EQ(10, stream->GetSize()); in TEST()
339 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()
345 stream = MemoryStream::OpenRef(buffer, nullptr); in TEST()
347 EXPECT_EQ(0, stream->GetPosition()); in TEST()
348 EXPECT_EQ(10, stream->GetSize()); in TEST()
353 StreamPtr stream = MemoryStream::CreateRef(&buffer, nullptr); in TEST() local
355 EXPECT_EQ(0, stream->GetPosition()); in TEST()
356 EXPECT_EQ(0, stream->GetSize()); in TEST()
357 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()
360 stream = MemoryStream::CreateRef(&buffer, nullptr); in TEST()
362 EXPECT_EQ(0, stream->GetPosition()); in TEST()
363 EXPECT_EQ(3, stream->GetSize()); in TEST()
364 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()
366 stream = MemoryStream::CreateRefForAppend(&buffer, nullptr); in TEST()
368 EXPECT_EQ(3, stream->GetPosition()); in TEST()
369 EXPECT_EQ(3, stream->GetSize()); in TEST()
370 EXPECT_TRUE(stream->WriteAllBlocking("d_1234", 6, nullptr)); in TEST()
372 EXPECT_EQ(9, stream->GetPosition()); in TEST()
373 EXPECT_EQ(9, stream->GetSize()); in TEST()
374 EXPECT_TRUE(stream->SetPosition(0, nullptr)); in TEST()
375 EXPECT_EQ(0, stream->GetPosition()); in TEST()
376 EXPECT_EQ(9, stream->GetSize()); in TEST()
377 EXPECT_TRUE(stream->CloseBlocking(nullptr)); in TEST()