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

Function write_all_at

tests/vectored_at.rs:431–448  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

429
430#[test]
431fn write_all_at() {
432 let dir = tempfile::tempdir().unwrap();
433 let file = check!(OpenOptions::new()
434 .create_new(true)
435 .read(true)
436 .write(true)
437 .open(dir.path().join("file")));
438 check!(write!(&file, "abcdefghijklmnopqrstuvwxyz"));
439 let buf0 = b"EFGHIJKL".to_vec();
440 let buf1 = b"MNOPQRST".to_vec();
441 check!(file.write_all_at(&buf0, 4));
442 check!(file.write_all_at(&buf1, 12));
443 assert_eq!(check!(file.stream_position()), 26);
444 let mut back = String::new();
445 check!(file.seek(std::io::SeekFrom::Start(0)));
446 check!(file.read_to_string(&mut back));
447 assert_eq!(back, "abcdEFGHIJKLMNOPQRSTuvwxyz");
448}
449
450#[test]
451fn write_all_after_end() {

Callers 1

write_all_atMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected