MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_stat

Function test_stat

tests/fs/stat.rs:2–19  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1#[test]
2fn test_stat() {
3 use rustix::fs::{fstat, lstat, stat, symlink};
4 use std::io::Write as _;
5
6 let tmp = tempfile::tempdir().unwrap();
7
8 let mut w = std::fs::File::create(tmp.path().join("file")).unwrap();
9 writeln!(&mut w, "Hello, File!").unwrap();
10
11 assert_eq!(fstat(&w).unwrap().st_size, 13);
12 assert_eq!(stat(tmp.path().join("file")).unwrap().st_size, 13);
13 assert_eq!(lstat(tmp.path().join("file")).unwrap().st_size, 13);
14
15 symlink("file", tmp.path().join("link")).unwrap();
16
17 assert_eq!(stat(tmp.path().join("link")).unwrap().st_size, 13);
18 assert_eq!(lstat(tmp.path().join("link")).unwrap().st_size, 4);
19}

Callers

nothing calls this directly

Calls 3

createFunction · 0.50
symlinkFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected