lib/scanner: add test for simple flow sequence

This commit is contained in:
Paul Stemmet 2021-07-30 09:44:56 +00:00 committed by Paul Stemmet
parent 9e295b8f72
commit 24a8f2b211
1 changed files with 25 additions and 0 deletions

View File

@ -1010,6 +1010,31 @@ mod tests
assert_eq!(s.scan.stats, stats_of(data)); assert_eq!(s.scan.stats, stats_of(data));
} }
#[test]
fn flow_collection_sequence()
{
use ScalarStyle::SingleQuote;
let data = "['a key': 'a value','another key': 'another value']";
let mut s = ScanIter::new(data);
tokens!(s =>
| Token::StreamStart(StreamEncoding::UTF8) => "expected start of stream",
| Token::FlowSequenceStart => "expected a flow sequence start '['",
| Token::Key => "expected a key",
| Token::Scalar(cow!("a key"), SingleQuote) => "expected a scalar key: 'a key'",
| Token::Value => "expected a value",
| Token::Scalar(cow!("a value"), SingleQuote) => "expected a scalar value: 'a value'",
| Token::FlowEntry => "expected a flow entry: ','",
| Token::Key => "expected a key",
| Token::Scalar(cow!("another key"), SingleQuote) => "expected a scalar key: 'another key'",
| Token::Value => "expected a value",
| Token::Scalar(cow!("another value"), SingleQuote) => "expected a scalar value: 'another value'",
| Token::FlowSequenceEnd => "expected a flow sequence end ']'",
| Token::StreamEnd => "expected end of stream",
@ None => "expected stream to be finished"
);
}
#[test] #[test]
fn chomp_comments() fn chomp_comments()
{ {