File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -136,3 +136,7 @@ required-features = ["serialize"]
136
136
[[test ]]
137
137
name = " serde-migrated"
138
138
required-features = [" serialize" ]
139
+
140
+ [[test ]]
141
+ name = " async_test"
142
+ required-features = [" async" ]
Original file line number Diff line number Diff line change
1
+ use std:: path:: PathBuf ;
2
+
3
+ use quick_xml:: events:: Event :: * ;
4
+ use quick_xml:: Reader ;
5
+
6
+ #[ tokio:: test]
7
+ async fn test_sample ( ) {
8
+ let src: & [ u8 ] = include_bytes ! ( "documents/sample_rss.xml" ) ;
9
+ let mut reader = Reader :: from_async_reader ( src) ;
10
+ let mut buf = Vec :: new ( ) ;
11
+ let mut count = 0 ;
12
+ loop {
13
+ match reader. read_event_into_async ( & mut buf) . await . unwrap ( ) {
14
+ Start ( _) => count += 1 ,
15
+ Decl ( e) => println ! ( "{:?}" , e. version( ) ) ,
16
+ Eof => break ,
17
+ _ => ( ) ,
18
+ }
19
+ buf. clear ( ) ;
20
+ }
21
+ println ! ( "{}" , count) ;
22
+ }
23
+
24
+ #[ cfg( feature = "async-fs" ) ]
25
+ #[ tokio:: test]
26
+ async fn test_read_file ( ) {
27
+ let path = PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
28
+ let mut reader = Reader :: from_file_async ( path. join ( "tests/documents/sample_rss.xml" ) )
29
+ . await
30
+ . unwrap ( ) ;
31
+ let mut buf = Vec :: new ( ) ;
32
+ let mut count = 0 ;
33
+ loop {
34
+ match reader. read_event_into_async ( & mut buf) . await . unwrap ( ) {
35
+ Start ( _) => count += 1 ,
36
+ Decl ( e) => println ! ( "{:?}" , e. version( ) ) ,
37
+ Eof => break ,
38
+ _ => ( ) ,
39
+ }
40
+ buf. clear ( ) ;
41
+ }
42
+ println ! ( "{}" , count) ;
43
+ }
You can’t perform that action at this time.
0 commit comments