diff --git a/src/scanner/mod.rs b/src/scanner/mod.rs index 8e87c63..be776a4 100644 --- a/src/scanner/mod.rs +++ b/src/scanner/mod.rs @@ -878,6 +878,42 @@ mod tests assert_eq!(s.scan.stats, stats_of(data)); } + #[test] + fn flow_collection_mapping_indicators() + { + let data = "{}"; + let mut s = ScanIter::new(data); + + // Note that the doubled braces here are because of Rust's + // fmtstr escaping rules. + tokens!(s => + | Token::StreamStart(StreamEncoding::UTF8) => "expected start of stream", + | Token::FlowMappingStart => "expected a flow mapping start '{{'", + | Token::FlowMappingEnd => "expected a flow mapping end '}}'", + | Token::StreamEnd => "expected end of stream", + @ None => "expected stream to be finished" + ); + + assert_eq!(s.scan.stats, stats_of(data)); + } + + #[test] + fn flow_collection_sequence_indicators() + { + let data = "[]"; + let mut s = ScanIter::new(data); + + tokens!(s => + | Token::StreamStart(StreamEncoding::UTF8) => "expected start of stream", + | Token::FlowSequenceStart => "expected a flow sequence start '['", + | Token::FlowSequenceEnd => "expected a flow sequence end ']'", + | Token::StreamEnd => "expected end of stream", + @ None => "expected stream to be finished" + ); + + assert_eq!(s.scan.stats, stats_of(data)); + } + #[test] fn chomp_comments() {