1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/std/wasi/testdata/std_fs_file_read.rs

17 lines
384 B
Rust
Raw Normal View History

// { "preopens": { "/fixture": "fixture" } }
use std::io::Read;
fn main() {
let mut file = std::fs::File::open("/fixture/file").unwrap();
let mut buffer = [0; 2];
assert_eq!(file.read(&mut buffer).unwrap(), 2);
assert_eq!(&buffer, b"fi");
assert_eq!(file.read(&mut buffer).unwrap(), 2);
assert_eq!(&buffer, b"le");
assert_eq!(file.read(&mut buffer).unwrap(), 1);
}