MCPcopy Create free account
hub / github.com/bytecodealliance/system-interface / read_exact_at

Function read_exact_at

tests/vectored_at.rs:119–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117
118#[test]
119fn read_exact_at() {
120 let dir = tempfile::tempdir().unwrap();
121 let file = check!(OpenOptions::new()
122 .create_new(true)
123 .read(true)
124 .write(true)
125 .open(dir.path().join("file")));
126 check!(write!(&file, "abcdefghijklmnopqrstuvwxyz"));
127 let mut buf0 = vec![0; 8];
128 let mut buf1 = vec![0; 8];
129 check!(file.read_exact_at(&mut buf0, 4));
130 check!(file.read_exact_at(&mut buf1, 12));
131 assert_eq!(check!(file.stream_position()), 26);
132 assert_eq!(&buf0, b"efghijkl");
133 assert_eq!(&buf1, b"mnopqrst");
134}
135
136/// Like `read_exact_at`, but with an unexpected EOF error.
137#[test]

Callers 3

read_exact_atMethod · 0.85
read_to_end_atFunction · 0.85
read_to_string_atFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected