-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::path::PathBuf; | ||
|
||
use quick_xml::events::Event::*; | ||
use quick_xml::Reader; | ||
|
||
#[tokio::test] | ||
async fn test_sample() { | ||
let src: &[u8] = include_bytes!("documents/sample_rss.xml"); | ||
let mut reader = Reader::from_async_reader(src); | ||
let mut buf = Vec::new(); | ||
let mut count = 0; | ||
loop { | ||
match reader.read_event_into_async(&mut buf).await.unwrap() { | ||
Start(_) => count += 1, | ||
Decl(e) => println!("{:?}", e.version()), | ||
Eof => break, | ||
_ => (), | ||
} | ||
buf.clear(); | ||
} | ||
println!("{}", count); | ||
} | ||
|
||
#[cfg(feature = "async-fs")] | ||
#[tokio::test] | ||
async fn test_read_file() { | ||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
let mut reader = Reader::from_file_async(path.join("tests/documents/sample_rss.xml")) | ||
.await | ||
.unwrap(); | ||
let mut buf = Vec::new(); | ||
let mut count = 0; | ||
loop { | ||
match reader.read_event_into_async(&mut buf).await.unwrap() { | ||
Start(_) => count += 1, | ||
Decl(e) => println!("{:?}", e.version()), | ||
Eof => break, | ||
_ => (), | ||
} | ||
buf.clear(); | ||
} | ||
println!("{}", count); | ||
} |