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

@@ -205,6 +205,7 @@ Project or files:
│   ├── async_await
│   ├── into
│   ├── iter
│   ├── misc
│   ├── ops
│   └── thread
├── __template
@@ -215,6 +216,7 @@ Project or files:
│   ├── colored_msg
│   ├── confy_table
│   ├── cursive-demo
│   ├── dialoguer-demo
│   ├── indicatif
│   ├── prettyprint
│   ├── rustyline
@@ -280,6 +282,6 @@ Project or files:
├── vec.rs
└── while.rs
249 directories, 40 files
251 directories, 40 files
```

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);
}