MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_slice

Function test_slice

src/buffer.rs:372–393  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

370 #[cfg(not(windows))]
371 #[test]
372 fn test_slice() {
373 use crate::io::read;
374 use std::io::{Seek, SeekFrom};
375
376 // We need to obtain input stream with contents that we can compare
377 // against, so open our own source file.
378 let mut input = std::fs::File::open("src/buffer.rs").unwrap();
379
380 let mut buf = [0_u8; 64];
381 let nread = read(&input, &mut buf).unwrap();
382 assert_eq!(nread, buf.len());
383 assert_eq!(
384 &buf[..58],
385 b"//! Utilities for functions that return data via buffers.\n"
386 );
387 input.seek(SeekFrom::End(-1)).unwrap();
388 let nread = read(&input, &mut buf).unwrap();
389 assert_eq!(nread, 1);
390 input.seek(SeekFrom::End(0)).unwrap();
391 let nread = read(&input, &mut buf).unwrap();
392 assert_eq!(nread, 0);
393 }
394
395 #[cfg(not(windows))]
396 #[test]

Callers

nothing calls this directly

Calls 3

openFunction · 0.70
readFunction · 0.50
seekMethod · 0.45

Tested by

no test coverage detected