feat: add tests

This commit is contained in:
2024-01-20 21:54:12 +08:00
parent 47830618e4
commit 0d1e08fcd1
2 changed files with 20 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
use std::io::{BufRead, Cursor, Read};
fn main() {
let mut cursor = Cursor::new(b"hello world\n001");
println!("{}", cursor.position());
let mut buff = [0_u8; 5];
cursor.read_exact(&mut buff).unwrap();
println!("{:x?}", buff);
println!("{}", cursor.position());
let mut s = String::new();
cursor.read_line(&mut s).unwrap();
println!("[{}]", s);
println!("{}", cursor.position());
let mut s2 = String::new();
cursor.read_to_string(&mut s2).unwrap();
println!("[{}]", s2);
}