MCPcopy Index your code
hub / github.com/bytecodealliance/system-interface / test_append

Function test_append

tests/fd_flags.rs:44–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43#[test]
44fn test_append() {
45 let tmpdir = tmpdir();
46 let mut file = check!(tmpdir.create("file"));
47 check!(write!(file, "Hello"));
48
49 let mut with_append =
50 check!(tmpdir.open_with("file", cap_fs_ext::OpenOptions::new().append(true)));
51 check!(write!(with_append, " world"));
52
53 let mut for_read = check!(tmpdir.open("file"));
54 let mut s = String::new();
55 check!(for_read.read_to_string(&mut s));
56 assert_eq!(s, "Hello world");
57
58 check!(with_append.seek(SeekFrom::Start(0)));
59 check!(write!(with_append, "The quick brown fox"));
60
61 let mut for_read = check!(tmpdir.open("file"));
62 let mut s = String::new();
63 check!(for_read.read_to_string(&mut s));
64 assert_eq!(s, "Hello worldThe quick brown fox");
65}

Callers

nothing calls this directly

Calls 1

tmpdirFunction · 0.85

Tested by

no test coverage detected