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

Function write_vectored

tests/vectored_at.rs:514–534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

512
513#[test]
514fn write_vectored() {
515 let dir = tempfile::tempdir().unwrap();
516 let file = check!(OpenOptions::new()
517 .create_new(true)
518 .read(true)
519 .write(true)
520 .open(dir.path().join("file")));
521 check!(write!(&file, "abcdefghijklmnopqrstuvwxyz"));
522 let buf0 = b"EFGHIJKL".to_vec();
523 let buf1 = b"MNOPQRST".to_vec();
524 let bufs = vec![IoSlice::new(&buf0), IoSlice::new(&buf1)];
525 let nwritten = check!(file.write_vectored(&bufs));
526 assert_eq!(check!(file.stream_position()), (26 + nwritten) as u64);
527 let mut back = String::new();
528 check!(file.seek(std::io::SeekFrom::Start(0)));
529 check!(file.read_to_string(&mut back));
530 assert_eq!(
531 back,
532 &"abcdefghijklmnopqrstuvwxyzEFGHIJKLMNOPQRST"[..26 + nwritten]
533 );
534}
535
536#[test]
537fn write_at() {

Callers 1

write_vectoredMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected