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

Function read_exact

tests/vectored_at.rs:193–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192#[test]
193fn read_exact() {
194 let dir = tempfile::tempdir().unwrap();
195 let file = check!(OpenOptions::new()
196 .create_new(true)
197 .read(true)
198 .write(true)
199 .open(dir.path().join("file")));
200 check!(write!(&file, "abcdefghijklmnopqrstuvwxyz"));
201 let mut buf0 = vec![0; 8];
202 let mut buf1 = vec![0; 8];
203 check!(file.seek(std::io::SeekFrom::Start(4)));
204 check!(file.read_exact(&mut buf0));
205 check!(file.read_exact(&mut buf1));
206 assert_eq!(check!(file.stream_position()), 20);
207 assert_eq!(&buf0, b"efghijkl");
208 assert_eq!(&buf1, b"mnopqrst");
209}
210
211#[test]
212fn read_vectored() {

Callers 1

read_exactMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected