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

16 lines
384 B
Rust

// { "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);
}