|
2 | 2 | //! |
3 | 3 | //! Name each module / test as `issue<GH number>` and keep sorted by issue number |
4 | 4 |
|
| 5 | +use std::io::BufReader; |
5 | 6 | use std::iter; |
6 | 7 | use std::sync::mpsc; |
7 | 8 |
|
8 | 9 | use quick_xml::errors::{Error, IllFormedError, SyntaxError}; |
9 | | -use quick_xml::events::{BytesDecl, BytesStart, BytesText, Event}; |
| 10 | +use quick_xml::events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event}; |
10 | 11 | use quick_xml::name::QName; |
11 | 12 | use quick_xml::reader::Reader; |
12 | 13 |
|
@@ -337,3 +338,29 @@ fn issue751() { |
337 | 338 | } |
338 | 339 | } |
339 | 340 | } |
| 341 | + |
| 342 | +/// Regression test for https://github.com/tafia/quick-xml/issues/774 |
| 343 | +/// |
| 344 | +/// Capacity of the buffer selected in that way, that "text" will be read into |
| 345 | +/// one internal buffer of `BufReader` in one `fill_buf()` call and `<` of the |
| 346 | +/// closing tag in the next call. |
| 347 | +#[test] |
| 348 | +fn issue774() { |
| 349 | + let xml = BufReader::with_capacity(9, b"<tag>text</tag>" as &[u8]); |
| 350 | + // ^0 ^9 |
| 351 | + let mut reader = Reader::from_reader(xml); |
| 352 | + let mut buf = Vec::new(); |
| 353 | + |
| 354 | + assert_eq!( |
| 355 | + reader.read_event_into(&mut buf).unwrap(), |
| 356 | + Event::Start(BytesStart::new("tag")) |
| 357 | + ); |
| 358 | + assert_eq!( |
| 359 | + reader.read_event_into(&mut buf).unwrap(), |
| 360 | + Event::Text(BytesText::new("text")) |
| 361 | + ); |
| 362 | + assert_eq!( |
| 363 | + reader.read_event_into(&mut buf).unwrap(), |
| 364 | + Event::End(BytesEnd::new("tag")) |
| 365 | + ); |
| 366 | +} |
0 commit comments