Skip to content

Commit 3c2b0a6

Browse files
committed
Add test for async
1 parent 543890d commit 3c2b0a6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@ required-features = ["serialize"]
129129
[[test]]
130130
name = "serde-migrated"
131131
required-features = ["serialize"]
132+
133+
[[test]]
134+
name = "async_test"
135+
required-features = ["async"]

tests/async_test.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use std::path::PathBuf;
2+
3+
use pretty_assertions::assert_eq;
4+
use quick_xml::events::Event::*;
5+
use quick_xml::Reader;
6+
7+
#[tokio::test]
8+
async fn test_sample() {
9+
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
10+
let mut reader = Reader::from_file_async(path.join("tests/documents/sample_rss.xml"))
11+
.await
12+
.unwrap();
13+
let mut buf = Vec::new();
14+
let mut count = 0;
15+
loop {
16+
match reader.read_event_into(&mut buf).await.unwrap() {
17+
Start(_) => count += 1,
18+
Decl(e) => println!("{:?}", e.version()),
19+
Eof => break,
20+
_ => (),
21+
}
22+
buf.clear();
23+
}
24+
println!("{}", count);
25+
}

0 commit comments

Comments
 (0)