summaryrefslogtreecommitdiffstats
path: root/third_party/rust/yaml-rust/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/yaml-rust/tests
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/yaml-rust/tests')
-rw-r--r--third_party/rust/yaml-rust/tests/quickcheck.rs21
-rw-r--r--third_party/rust/yaml-rust/tests/spec_test.rs140
-rw-r--r--third_party/rust/yaml-rust/tests/spec_test.rs.inc1513
-rw-r--r--third_party/rust/yaml-rust/tests/specexamples.rs.inc337
-rwxr-xr-xthird_party/rust/yaml-rust/tests/specs/cpp2rust.rb78
-rw-r--r--third_party/rust/yaml-rust/tests/specs/handler_spec_test.cpp1532
-rw-r--r--third_party/rust/yaml-rust/tests/specs/libyaml_fail-01.yaml6
-rw-r--r--third_party/rust/yaml-rust/tests/specs/libyaml_fail-02.yaml7
-rw-r--r--third_party/rust/yaml-rust/tests/specs/libyaml_fail-03.yaml5
-rw-r--r--third_party/rust/yaml-rust/tests/test_round_trip.rs65
10 files changed, 3704 insertions, 0 deletions
diff --git a/third_party/rust/yaml-rust/tests/quickcheck.rs b/third_party/rust/yaml-rust/tests/quickcheck.rs
new file mode 100644
index 0000000000..0efd679978
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/quickcheck.rs
@@ -0,0 +1,21 @@
+extern crate yaml_rust;
+#[macro_use]
+extern crate quickcheck;
+
+use quickcheck::TestResult;
+use yaml_rust::{Yaml, YamlEmitter, YamlLoader};
+
+quickcheck! {
+ fn test_check_weird_keys(xs: Vec<String>) -> TestResult {
+ let mut out_str = String::new();
+ let input = Yaml::Array(xs.into_iter().map(Yaml::String).collect());
+ {
+ let mut emitter = YamlEmitter::new(&mut out_str);
+ emitter.dump(&input).unwrap();
+ }
+ match YamlLoader::load_from_str(&out_str) {
+ Ok(output) => TestResult::from_bool(output.len() == 1 && input == output[0]),
+ Err(err) => TestResult::error(err.to_string()),
+ }
+ }
+}
diff --git a/third_party/rust/yaml-rust/tests/spec_test.rs b/third_party/rust/yaml-rust/tests/spec_test.rs
new file mode 100644
index 0000000000..442728f4f3
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/spec_test.rs
@@ -0,0 +1,140 @@
+#![allow(dead_code)]
+#![allow(non_upper_case_globals)]
+extern crate yaml_rust;
+
+use yaml_rust::parser::{Event, EventReceiver, Parser};
+use yaml_rust::scanner::TScalarStyle;
+
+// These names match the names used in the C++ test suite.
+#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))]
+#[derive(Clone, PartialEq, PartialOrd, Debug)]
+enum TestEvent {
+ OnDocumentStart,
+ OnDocumentEnd,
+ OnSequenceStart,
+ OnSequenceEnd,
+ OnMapStart,
+ OnMapEnd,
+ OnScalar,
+ OnAlias,
+ OnNull,
+}
+
+struct YamlChecker {
+ pub evs: Vec<TestEvent>,
+}
+
+impl EventReceiver for YamlChecker {
+ fn on_event(&mut self, ev: Event) {
+ let tev = match ev {
+ Event::DocumentStart => TestEvent::OnDocumentStart,
+ Event::DocumentEnd => TestEvent::OnDocumentEnd,
+ Event::SequenceStart(..) => TestEvent::OnSequenceStart,
+ Event::SequenceEnd => TestEvent::OnSequenceEnd,
+ Event::MappingStart(..) => TestEvent::OnMapStart,
+ Event::MappingEnd => TestEvent::OnMapEnd,
+ Event::Scalar(ref v, style, _, _) => {
+ if v == "~" && style == TScalarStyle::Plain {
+ TestEvent::OnNull
+ } else {
+ TestEvent::OnScalar
+ }
+ }
+ Event::Alias(_) => TestEvent::OnAlias,
+ _ => return, // ignore other events
+ };
+ self.evs.push(tev);
+ }
+}
+
+fn str_to_test_events(docs: &str) -> Vec<TestEvent> {
+ let mut p = YamlChecker { evs: Vec::new() };
+ let mut parser = Parser::new(docs.chars());
+ parser.load(&mut p, true).unwrap();
+ p.evs
+}
+
+macro_rules! assert_next {
+ ($v:expr, $p:pat) => {
+ match $v.next().unwrap() {
+ $p => {}
+ e => {
+ panic!("unexpected event: {:?}", e);
+ }
+ }
+ };
+}
+
+// auto generated from handler_spec_test.cpp
+include!("specexamples.rs.inc");
+include!("spec_test.rs.inc");
+
+// hand-crafted tests
+//#[test]
+//fn test_hc_alias() {
+//}
+
+#[test]
+fn test_mapvec_legal() {
+ use yaml_rust::yaml::{Array, Hash, Yaml};
+ use yaml_rust::{YamlEmitter, YamlLoader};
+
+ // Emitting a `map<map<seq<_>>, _>` should result in legal yaml that
+ // we can parse.
+
+ let mut key = Array::new();
+ key.push(Yaml::Integer(1));
+ key.push(Yaml::Integer(2));
+ key.push(Yaml::Integer(3));
+
+ let mut keyhash = Hash::new();
+ keyhash.insert(Yaml::String("key".into()), Yaml::Array(key));
+
+ let mut val = Array::new();
+ val.push(Yaml::Integer(4));
+ val.push(Yaml::Integer(5));
+ val.push(Yaml::Integer(6));
+
+ let mut hash = Hash::new();
+ hash.insert(Yaml::Hash(keyhash), Yaml::Array(val));
+
+ let mut out_str = String::new();
+ {
+ let mut emitter = YamlEmitter::new(&mut out_str);
+ emitter.dump(&Yaml::Hash(hash)).unwrap();
+ }
+
+ // At this point, we are tempted to naively render like this:
+ //
+ // ```yaml
+ // ---
+ // {key:
+ // - 1
+ // - 2
+ // - 3}:
+ // - 4
+ // - 5
+ // - 6
+ // ```
+ //
+ // However, this doesn't work, because the key sequence [1, 2, 3] is
+ // rendered in block mode, which is not legal (as far as I can tell)
+ // inside the flow mode of the key. We need to either fully render
+ // everything that's in a key in flow mode (which may make for some
+ // long lines), or use the explicit map identifier '?':
+ //
+ // ```yaml
+ // ---
+ // ?
+ // key:
+ // - 1
+ // - 2
+ // - 3
+ // :
+ // - 4
+ // - 5
+ // - 6
+ // ```
+
+ YamlLoader::load_from_str(&out_str).unwrap();
+}
diff --git a/third_party/rust/yaml-rust/tests/spec_test.rs.inc b/third_party/rust/yaml-rust/tests/spec_test.rs.inc
new file mode 100644
index 0000000000..bb50b3b3cc
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/spec_test.rs.inc
@@ -0,0 +1,1513 @@
+#[test]
+fn test_ex2_1_seq_scalars() {
+ let mut v = str_to_test_events(EX2_1).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_2_mapping_scalars_to_scalars() {
+ let mut v = str_to_test_events(EX2_2).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_3_mapping_scalars_to_sequences() {
+ let mut v = str_to_test_events(EX2_3).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_4_sequence_of_mappings() {
+ let mut v = str_to_test_events(EX2_4).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_5_sequence_of_sequences() {
+ let mut v = str_to_test_events(EX2_5).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_6_mapping_of_mappings() {
+ let mut v = str_to_test_events(EX2_6).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_7_two_documents_in_a_stream() {
+ let mut v = str_to_test_events(EX2_7).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_8_play_by_play_feed() {
+ let mut v = str_to_test_events(EX2_8).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_9_single_document_with_two_comments() {
+ let mut v = str_to_test_events(EX2_9).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_10_simple_anchor() {
+ let mut v = str_to_test_events(EX2_10).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_11_mapping_between_sequences() {
+ let mut v = str_to_test_events(EX2_11).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_12_compact_nested_mapping() {
+ let mut v = str_to_test_events(EX2_12).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_13_in_literals_newlines_are_preserved() {
+ let mut v = str_to_test_events(EX2_13).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_14_in_folded_scalars_newlines_become_spaces() {
+ let mut v = str_to_test_events(EX2_14).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_15_folded_newlines_are_preserved_for_more_indented_and_blank_lines() {
+ let mut v = str_to_test_events(EX2_15).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_16_indentation_determines_scope() {
+ let mut v = str_to_test_events(EX2_16).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_17_quoted_scalars() {
+ let mut v = str_to_test_events(EX2_17).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_18_multi_line_flow_scalars() {
+ let mut v = str_to_test_events(EX2_18).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_23_various_explicit_tags() {
+ let mut v = str_to_test_events(EX2_23).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_24_global_tags() {
+ let mut v = str_to_test_events(EX2_24).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_25_unordered_sets() {
+ let mut v = str_to_test_events(EX2_25).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_26_ordered_mappings() {
+ let mut v = str_to_test_events(EX2_26).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_27_invoice() {
+ let mut v = str_to_test_events(EX2_27).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex2_28_log_file() {
+ let mut v = str_to_test_events(EX2_28).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_3_block_structure_indicators() {
+ let mut v = str_to_test_events(EX5_3).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_4_flow_structure_indicators() {
+ let mut v = str_to_test_events(EX5_4).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_6_node_property_indicators() {
+ let mut v = str_to_test_events(EX5_6).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_7_block_scalar_indicators() {
+ let mut v = str_to_test_events(EX5_7).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_8_quoted_scalar_indicators() {
+ let mut v = str_to_test_events(EX5_8).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_11_line_break_characters() {
+ let mut v = str_to_test_events(EX5_11).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_12_tabs_and_spaces() {
+ let mut v = str_to_test_events(EX5_12).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex5_13_escaped_characters() {
+ let mut v = str_to_test_events(EX5_13).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_1_indentation_spaces() {
+ let mut v = str_to_test_events(EX6_1).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_2_indentation_indicators() {
+ let mut v = str_to_test_events(EX6_2).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_3_separation_spaces() {
+ let mut v = str_to_test_events(EX6_3).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_4_line_prefixes() {
+ let mut v = str_to_test_events(EX6_4).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_5_empty_lines() {
+ let mut v = str_to_test_events(EX6_5).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_6_line_folding() {
+ let mut v = str_to_test_events(EX6_6).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_7_block_folding() {
+ let mut v = str_to_test_events(EX6_7).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_8_flow_folding() {
+ let mut v = str_to_test_events(EX6_8).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_9_separated_comment() {
+ let mut v = str_to_test_events(EX6_9).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_12_separation_spaces_ii() {
+ let mut v = str_to_test_events(EX6_12).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_13_reserved_directives() {
+ let mut v = str_to_test_events(EX6_13).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_14_yaml_directive() {
+ let mut v = str_to_test_events(EX6_14).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_16_tag_directive() {
+ let mut v = str_to_test_events(EX6_16).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_18_primary_tag_handle() {
+ let mut v = str_to_test_events(EX6_18).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_19_secondary_tag_handle() {
+ let mut v = str_to_test_events(EX6_19).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_20_tag_handles() {
+ let mut v = str_to_test_events(EX6_20).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_21_local_tag_prefix() {
+ let mut v = str_to_test_events(EX6_21).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_22_global_tag_prefix() {
+ let mut v = str_to_test_events(EX6_22).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_23_node_properties() {
+ let mut v = str_to_test_events(EX6_23).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_24_verbatim_tags() {
+ let mut v = str_to_test_events(EX6_24).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_26_tag_shorthands() {
+ let mut v = str_to_test_events(EX6_26).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_28_non_specific_tags() {
+ let mut v = str_to_test_events(EX6_28).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex6_29_node_anchors() {
+ let mut v = str_to_test_events(EX6_29).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_1_alias_nodes() {
+ let mut v = str_to_test_events(EX7_1).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[allow(dead_code)]
+fn test_ex7_2_empty_nodes() {
+ let mut v = str_to_test_events(EX7_2).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_3_completely_empty_nodes() {
+ let mut v = str_to_test_events(EX7_3).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_4_double_quoted_implicit_keys() {
+ let mut v = str_to_test_events(EX7_4).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_5_double_quoted_line_breaks() {
+ let mut v = str_to_test_events(EX7_5).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_6_double_quoted_lines() {
+ let mut v = str_to_test_events(EX7_6).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_7_single_quoted_characters() {
+ let mut v = str_to_test_events(EX7_7).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_8_single_quoted_implicit_keys() {
+ let mut v = str_to_test_events(EX7_8).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_9_single_quoted_lines() {
+ let mut v = str_to_test_events(EX7_9).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[allow(dead_code)]
+fn test_ex7_10_plain_characters() {
+ let mut v = str_to_test_events(EX7_10).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_11_plain_implicit_keys() {
+ let mut v = str_to_test_events(EX7_11).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_12_plain_lines() {
+ let mut v = str_to_test_events(EX7_12).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_13_flow_sequence() {
+ let mut v = str_to_test_events(EX7_13).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_14_flow_sequence_entries() {
+ let mut v = str_to_test_events(EX7_14).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_15_flow_mappings() {
+ let mut v = str_to_test_events(EX7_15).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_16_flow_mapping_entries() {
+ let mut v = str_to_test_events(EX7_16).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[allow(dead_code)]
+fn test_ex7_17_flow_mapping_separate_values() {
+ let mut v = str_to_test_events(EX7_17).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_18_flow_mapping_adjacent_values() {
+ let mut v = str_to_test_events(EX7_18).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_19_single_pair_flow_mappings() {
+ let mut v = str_to_test_events(EX7_19).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_20_single_pair_explicit_entry() {
+ let mut v = str_to_test_events(EX7_20).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[allow(dead_code)]
+fn test_ex7_21_single_pair_implicit_entries() {
+ let mut v = str_to_test_events(EX7_21).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_23_flow_content() {
+ let mut v = str_to_test_events(EX7_23).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex7_24_flow_nodes() {
+ let mut v = str_to_test_events(EX7_24).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnAlias);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_1_block_scalar_header() {
+ let mut v = str_to_test_events(EX8_1).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[allow(dead_code)]
+fn test_ex8_2_block_indentation_header() {
+ let mut v = str_to_test_events(EX8_2).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_4_chomping_final_line_break() {
+ let mut v = str_to_test_events(EX8_4).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_6_empty_scalar_chomping() {
+ let mut v = str_to_test_events(EX8_6).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_7_literal_scalar() {
+ let mut v = str_to_test_events(EX8_7).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_8_literal_content() {
+ let mut v = str_to_test_events(EX8_8).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_9_folded_scalar() {
+ let mut v = str_to_test_events(EX8_9).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_10_folded_lines() {
+ let mut v = str_to_test_events(EX8_10).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_11_more_indented_lines() {
+ let mut v = str_to_test_events(EX8_11).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_12_empty_separation_lines() {
+ let mut v = str_to_test_events(EX8_12).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_13_final_empty_lines() {
+ let mut v = str_to_test_events(EX8_13).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_14_block_sequence() {
+ let mut v = str_to_test_events(EX8_14).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_15_block_sequence_entry_types() {
+ let mut v = str_to_test_events(EX8_15).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_16_block_mappings() {
+ let mut v = str_to_test_events(EX8_16).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_17_explicit_block_mapping_entries() {
+ let mut v = str_to_test_events(EX8_17).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_18_implicit_block_mapping_entries() {
+ let mut v = str_to_test_events(EX8_18).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnNull);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_19_compact_block_mappings() {
+ let mut v = str_to_test_events(EX8_19).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_20_block_node_types() {
+ let mut v = str_to_test_events(EX8_20).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
+#[test]
+fn test_ex8_22_block_collection_nodes() {
+ let mut v = str_to_test_events(EX8_22).into_iter();
+ assert_next!(v, TestEvent::OnDocumentStart);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnSequenceEnd);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapStart);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnScalar);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnMapEnd);
+ assert_next!(v, TestEvent::OnDocumentEnd);
+}
+
diff --git a/third_party/rust/yaml-rust/tests/specexamples.rs.inc b/third_party/rust/yaml-rust/tests/specexamples.rs.inc
new file mode 100644
index 0000000000..a5398c3ab1
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specexamples.rs.inc
@@ -0,0 +1,337 @@
+const EX2_1 : &'static str =
+ "- Mark McGwire\n- Sammy Sosa\n- Ken Griffey";
+
+const EX2_2 : &'static str =
+ "hr: 65 # Home runs\navg: 0.278 # Batting average\nrbi: 147 # Runs Batted In";
+
+const EX2_3 : &'static str =
+ "american:\n- Boston Red Sox\n- Detroit Tigers\n- New York Yankees\nnational:\n- New York Mets\n- Chicago Cubs\n- Atlanta Braves";
+
+const EX2_4 : &'static str =
+ "-\n name: Mark McGwire\n hr: 65\n avg: 0.278\n-\n name: Sammy Sosa\n hr: 63\n avg: 0.288";
+
+const EX2_5 : &'static str =
+ "- [name , hr, avg ]\n- [Mark McGwire, 65, 0.278]\n- [Sammy Sosa , 63, 0.288]";
+
+const EX2_6 : &'static str =
+ "Mark McGwire: {hr: 65, avg: 0.278}\nSammy Sosa: {\n hr: 63,\n avg: 0.288\n }";
+
+const EX2_7 : &'static str =
+ "# Ranking of 1998 home runs\n---\n- Mark McGwire\n- Sammy Sosa\n- Ken Griffey\n\n# Team ranking\n---\n- Chicago Cubs\n- St Louis Cardinals";
+
+const EX2_8 : &'static str =
+ "---\ntime: 20:03:20\nplayer: Sammy Sosa\naction: strike (miss)\n...\n---\ntime: 20:03:47\nplayer: Sammy Sosa\naction: grand slam\n...";
+
+const EX2_9 : &'static str =
+ "---\nhr: # 1998 hr ranking\n - Mark McGwire\n - Sammy Sosa\nrbi:\n # 1998 rbi ranking\n - Sammy Sosa\n - Ken Griffey";
+
+const EX2_10 : &'static str =
+ "---\nhr:\n - Mark McGwire\n # Following node labeled SS\n - &SS Sammy Sosa\nrbi:\n - *SS # Subsequent occurrence\n - Ken Griffey";
+
+const EX2_11 : &'static str =
+ "? - Detroit Tigers\n - Chicago cubs\n:\n - 2001-07-23\n\n? [ New York Yankees,\n Atlanta Braves ]\n: [ 2001-07-02, 2001-08-12,\n 2001-08-14 ]";
+
+const EX2_12 : &'static str =
+ "---\n# Products purchased\n- item : Super Hoop\n quantity: 1\n- item : Basketball\n quantity: 4\n- item : Big Shoes\n quantity: 1";
+
+const EX2_13 : &'static str =
+ "# ASCII Art\n--- |\n \\//||\\/||\n // || ||__";
+
+const EX2_14 : &'static str =
+ "--- >\n Mark McGwire's\n year was crippled\n by a knee injury.";
+
+const EX2_15 : &'static str =
+ ">\n Sammy Sosa completed another\n fine season with great stats.\n \n 63 Home Runs\n 0.288 Batting Average\n \n What a year!";
+
+const EX2_16 : &'static str =
+ "name: Mark McGwire\naccomplishment: >\n Mark set a major league\n home run record in 1998.\nstats: |\n 65 Home Runs\n 0.278 Batting Average\n";
+
+const EX2_17 : &'static str =
+ "unicode: \"Sosa did fine.\\u263A\"\ncontrol: \"\\b1998\\t1999\\t2000\\n\"\nhex esc: \"\\x0d\\x0a is \\r\\n\"\n\nsingle: '\"Howdy!\" he cried.'\nquoted: ' # Not a ''comment''.'\ntie-fighter: '|\\-*-/|'";
+
+const EX2_18 : &'static str =
+ "plain:\n This unquoted scalar\n spans many lines.\n\nquoted: \"So does this\n quoted scalar.\\n\"";
+
+// TODO: 2.19 - 2.22 schema tags
+
+const EX2_23 : &'static str =
+ "---\nnot-date: !!str 2002-04-28\n\npicture: !!binary |\n R0lGODlhDAAMAIQAAP//9/X\n 17unp5WZmZgAAAOfn515eXv\n Pz7Y6OjuDg4J+fn5OTk6enp\n 56enmleECcgggoBADs=\n\napplication specific tag: !something |\n The semantics of the tag\n above may be different for\n different documents.";
+
+const EX2_24 : &'static str =
+ "%TAG ! tag:clarkevans.com,2002:\n--- !shape\n # Use the ! handle for presenting\n # tag:clarkevans.com,2002:circle\n- !circle\n center: &ORIGIN {x: 73, y: 129}\n radius: 7\n- !line\n start: *ORIGIN\n finish: { x: 89, y: 102 }\n- !label\n start: *ORIGIN\n color: 0xFFEEBB\n text: Pretty vector drawing.";
+
+const EX2_25 : &'static str =
+ "# Sets are represented as a\n# Mapping where each key is\n# associated with a null value\n--- !!set\n? Mark McGwire\n? Sammy Sosa\n? Ken Griffey";
+
+const EX2_26 : &'static str =
+ "# Ordered maps are represented as\n# A sequence of mappings, with\n# each mapping having one key\n--- !!omap\n- Mark McGwire: 65\n- Sammy Sosa: 63\n- Ken Griffey: 58";
+
+const EX2_27 : &'static str =
+ "--- !<tag:clarkevans.com,2002:invoice>\ninvoice: 34843\ndate : 2001-01-23\nbill-to: &id001\n given : Chris\n family : Dumars\n address:\n lines: |\n 458 Walkman Dr.\n Suite #292\n city : Royal Oak\n state : MI\n postal : 48046\nship-to: *id001\nproduct:\n - sku : BL394D\n quantity : 4\n description : Basketball\n price : 450.00\n - sku : BL4438H\n quantity : 1\n description : Super Hoop\n price : 2392.00\ntax : 251.42\ntotal: 4443.52\ncomments:\n Late afternoon is best.\n Backup contact is Nancy\n Billsmer @ 338-4338.";
+
+const EX2_28 : &'static str =
+ "---\nTime: 2001-11-23 15:01:42 -5\nUser: ed\nWarning:\n This is an error message\n for the log file\n---\nTime: 2001-11-23 15:02:31 -5\nUser: ed\nWarning:\n A slightly different error\n message.\n---\nDate: 2001-11-23 15:03:17 -5\nUser: ed\nFatal:\n Unknown variable \"bar\"\nStack:\n - file: TopClass.py\n line: 23\n code: |\n x = MoreObject(\"345\\n\")\n - file: MoreClass.py\n line: 58\n code: |-\n foo = bar";
+
+// TODO: 5.1 - 5.2 BOM
+
+const EX5_3 : &'static str =
+ "sequence:\n- one\n- two\nmapping:\n ? sky\n : blue\n sea : green";
+
+const EX5_4 : &'static str =
+ "sequence: [ one, two, ]\nmapping: { sky: blue, sea: green }";
+
+const EX5_5 : &'static str = "# Comment only.";
+
+const EX5_6 : &'static str =
+ "anchored: !local &anchor value\nalias: *anchor";
+
+const EX5_7 : &'static str =
+ "literal: |\n some\n text\nfolded: >\n some\n text\n";
+
+const EX5_8 : &'static str =
+ "single: 'text'\ndouble: \"text\"";
+
+// TODO: 5.9 directive
+// TODO: 5.10 reserved indicator
+
+const EX5_11 : &'static str =
+ "|\n Line break (no glyph)\n Line break (glyphed)\n";
+
+const EX5_12 : &'static str =
+ "# Tabs and spaces\nquoted: \"Quoted\t\"\nblock: |\n void main() {\n \tprintf(\"Hello, world!\\n\");\n }";
+
+const EX5_13 : &'static str =
+ "\"Fun with \\\\\n\\\" \\a \\b \\e \\f \\\n\\n \\r \\t \\v \\0 \\\n\\ \\_ \\N \\L \\P \\\n\\x41 \\u0041 \\U00000041\"";
+
+const EX5_14 : &'static str =
+ "Bad escapes:\n \"\\c\n \\xq-\"";
+
+const EX6_1 : &'static str =
+ " # Leading comment line spaces are\n # neither content nor indentation.\n \nNot indented:\n By one space: |\n By four\n spaces\n Flow style: [ # Leading spaces\n By two, # in flow style\n Also by two, # are neither\n \tStill by two # content nor\n ] # indentation.";
+
+const EX6_2 : &'static str =
+ "? a\n: -\tb\n - -\tc\n - d";
+
+const EX6_3 : &'static str =
+ "- foo:\t bar\n- - baz\n -\tbaz";
+
+const EX6_4 : &'static str =
+ "plain: text\n lines\nquoted: \"text\n \tlines\"\nblock: |\n text\n \tlines\n";
+
+const EX6_5 : &'static str =
+ "Folding:\n \"Empty line\n \t\n as a line feed\"\nChomping: |\n Clipped empty lines\n ";
+
+const EX6_6 : &'static str =
+ ">-\n trimmed\n \n \n\n as\n space";
+
+const EX6_7 : &'static str =
+ ">\n foo \n \n \t bar\n\n baz\n";
+
+const EX6_8 : &'static str =
+ "\"\n foo \n \n \t bar\n\n baz\n\"";
+
+const EX6_9 : &'static str =
+ "key: # Comment\n value";
+
+const EX6_10 : &'static str =
+ " # Comment\n \n\n";
+
+const EX6_11 : &'static str =
+ "key: # Comment\n # lines\n value\n\n";
+
+const EX6_12 : &'static str =
+ "{ first: Sammy, last: Sosa }:\n# Statistics:\n hr: # Home runs\n 65\n avg: # Average\n 0.278";
+
+const EX6_13 : &'static str =
+ "%FOO bar baz # Should be ignored\n # with a warning.\n--- \"foo\"";
+
+const EX6_14 : &'static str =
+ "%YAML 1.3 # Attempt parsing\n # with a warning\n---\n\"foo\"";
+
+const EX6_15 : &'static str =
+ "%YAML 1.2\n%YAML 1.1\nfoo";
+
+const EX6_16 : &'static str =
+ "%TAG !yaml! tag:yaml.org,2002:\n---\n!yaml!str \"foo\"";
+
+const EX6_17 : &'static str =
+ "%TAG ! !foo\n%TAG ! !foo\nbar";
+
+const EX6_18 : &'static str =
+ "# Private\n!foo \"bar\"\n...\n# Global\n%TAG ! tag:example.com,2000:app/\n---\n!foo \"bar\"";
+
+const EX6_19 : &'static str =
+ "%TAG !! tag:example.com,2000:app/\n---\n!!int 1 - 3 # Interval, not integer";
+
+const EX6_20 : &'static str =
+ "%TAG !e! tag:example.com,2000:app/\n---\n!e!foo \"bar\"";
+
+const EX6_21 : &'static str =
+ "%TAG !m! !my-\n--- # Bulb here\n!m!light fluorescent\n...\n%TAG !m! !my-\n--- # Color here\n!m!light green";
+
+const EX6_22 : &'static str =
+ "%TAG !e! tag:example.com,2000:app/\n---\n- !e!foo \"bar\"";
+
+const EX6_23 : &'static str =
+ "!!str &a1 \"foo\":\n !!str bar\n&a2 baz : *a1";
+
+const EX6_24 : &'static str =
+ "!<tag:yaml.org,2002:str> foo :\n !<!bar> baz";
+
+const EX6_25 : &'static str =
+ "- !<!> foo\n- !<$:?> bar\n";
+
+const EX6_26 : &'static str =
+ "%TAG !e! tag:example.com,2000:app/\n---\n- !local foo\n- !!str bar\n- !e!tag%21 baz\n";
+
+const EX6_27a : &'static str =
+ "%TAG !e! tag:example,2000:app/\n---\n- !e! foo";
+
+const EX6_27b : &'static str =
+ "%TAG !e! tag:example,2000:app/\n---\n- !h!bar baz";
+
+const EX6_28 : &'static str =
+ "# Assuming conventional resolution:\n- \"12\"\n- 12\n- ! 12";
+
+const EX6_29 : &'static str =
+ "First occurrence: &anchor Value\nSecond occurrence: *anchor";
+
+const EX7_1 : &'static str =
+ "First occurrence: &anchor Foo\nSecond occurrence: *anchor\nOverride anchor: &anchor Bar\nReuse anchor: *anchor";
+
+const EX7_2 : &'static str =
+ "{\n foo : !!str,\n !!str : bar,\n}";
+
+const EX7_3 : &'static str =
+ "{\n ? foo :,\n : bar,\n}\n";
+
+const EX7_4 : &'static str =
+ "\"implicit block key\" : [\n \"implicit flow key\" : value,\n ]";
+
+const EX7_5 : &'static str =
+ "\"folded \nto a space,\t\n \nto a line feed, or \t\\\n \\ \tnon-content\"";
+
+const EX7_6 : &'static str =
+ "\" 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty \"";
+
+const EX7_7 : &'static str = " 'here''s to \"quotes\"'";
+
+const EX7_8 : &'static str =
+ "'implicit block key' : [\n 'implicit flow key' : value,\n ]";
+
+const EX7_9 : &'static str =
+ "' 1st non-empty\n\n 2nd non-empty \n\t3rd non-empty '";
+
+const EX7_10 : &'static str =
+ "# Outside flow collection:\n- ::vector\n- \": - ()\"\n- Up, up, and away!\n- -123\n- http://example.com/foo#bar\n# Inside flow collection:\n- [ ::vector,\n \": - ()\",\n \"Up, up, and away!\",\n -123,\n http://example.com/foo#bar ]";
+
+const EX7_11 : &'static str =
+ "implicit block key : [\n implicit flow key : value,\n ]";
+
+const EX7_12 : &'static str =
+ "1st non-empty\n\n 2nd non-empty \n\t3rd non-empty";
+
+const EX7_13 : &'static str =
+ "- [ one, two, ]\n- [three ,four]";
+
+const EX7_14 : &'static str =
+ "[\n\"double\n quoted\", 'single\n quoted',\nplain\n text, [ nested ],\nsingle: pair,\n]";
+
+const EX7_15 : &'static str =
+ "- { one : two , three: four , }\n- {five: six,seven : eight}";
+
+const EX7_16 : &'static str =
+ "{\n? explicit: entry,\nimplicit: entry,\n?\n}";
+
+const EX7_17 : &'static str =
+ "{\nunquoted : \"separate\",\nhttp://foo.com,\nomitted value:,\n: omitted key,\n}";
+
+const EX7_18 : &'static str =
+ "{\n\"adjacent\":value,\n\"readable\":value,\n\"empty\":\n}";
+
+const EX7_19 : &'static str =
+ "[\nfoo: bar\n]";
+
+const EX7_20 : &'static str =
+ "[\n? foo\n bar : baz\n]";
+
+const EX7_21 : &'static str =
+ "- [ YAML : separate ]\n- [ : empty key entry ]\n- [ {JSON: like}:adjacent ]";
+
+const EX7_22 : &'static str =
+ "[ foo\n bar: invalid,"; // Note: we don't check (on purpose) the >1K chars for an
+ // implicit key
+
+const EX7_23 : &'static str =
+ "- [ a, b ]\n- { a: b }\n- \"a\"\n- 'b'\n- c";
+
+const EX7_24 : &'static str =
+ "- !!str \"a\"\n- 'b'\n- &anchor \"c\"\n- *anchor\n- !!str";
+
+const EX8_1 : &'static str =
+ "- | # Empty header\n literal\n- >1 # Indentation indicator\n folded\n- |+ # Chomping indicator\n keep\n\n- >1- # Both indicators\n strip\n";
+
+const EX8_2 : &'static str =
+ "- |\n detected\n- >\n \n \n # detected\n- |1\n explicit\n- >\n \t\n detected\n";
+
+const EX8_3a : &'static str =
+ "- |\n \n text";
+
+const EX8_3b : &'static str =
+ "- >\n text\n text";
+
+const EX8_3c : &'static str =
+ "- |2\n text";
+
+const EX8_4 : &'static str =
+ "strip: |-\n text\nclip: |\n text\nkeep: |+\n text\n";
+
+const EX8_5 : &'static str =
+ " # Strip\n # Comments:\nstrip: |-\n # text\n \n # Clip\n # comments:\n\nclip: |\n # text\n \n # Keep\n # comments:\n\nkeep: |+\n # text\n\n # Trail\n # Comments\n";
+
+const EX8_6 : &'static str =
+ "strip: >-\n\nclip: >\n\nkeep: |+\n\n";
+
+const EX8_7 : &'static str =
+ "|\n literal\n \ttext\n\n";
+
+const EX8_8 : &'static str =
+ "|\n \n \n literal\n \n \n text\n\n # Comment\n";
+
+const EX8_9 : &'static str =
+ ">\n folded\n text\n\n";
+
+const EX8_10 : &'static str =
+ ">\n\n folded\n line\n\n next\n line\n * bullet\n\n * list\n * lines\n\n last\n line\n\n# Comment\n";
+
+const EX8_11 : &'static str = EX8_10;
+const EX8_12 : &'static str = EX8_10;
+const EX8_13 : &'static str = EX8_10;
+
+const EX8_14 : &'static str =
+ "block sequence:\n - one\n - two : three\n";
+
+const EX8_15 : &'static str =
+ "- # Empty\n- |\n block node\n- - one # Compact\n - two # sequence\n- one: two # Compact mapping\n";
+
+const EX8_16 : &'static str =
+ "block mapping:\n key: value\n";
+
+const EX8_17 : &'static str =
+ "? explicit key # Empty value\n? |\n block key\n: - one # Explicit compact\n - two # block value\n";
+
+// XXX libyaml failed this test
+const EX8_18 : &'static str =
+ "plain key: in-line value\n: # Both empty\n\"quoted key\":\n- entry\n";
+
+const EX8_19 : &'static str =
+ "- sun: yellow\n- ? earth: blue\n : moon: white\n";
+
+const EX8_20 : &'static str =
+ "-\n \"flow in block\"\n- >\n Block scalar\n- !!map # Block collection\n foo : bar\n";
+
+const EX8_21 : &'static str =
+ "literal: |2\n value\nfolded:\n !foo\n >1\n value\n";
+
+const EX8_22 : &'static str =
+ "sequence: !!seq\n- entry\n- !!seq\n - nested\nmapping: !!map\n foo: bar\n";
diff --git a/third_party/rust/yaml-rust/tests/specs/cpp2rust.rb b/third_party/rust/yaml-rust/tests/specs/cpp2rust.rb
new file mode 100755
index 0000000000..25813c87a6
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specs/cpp2rust.rb
@@ -0,0 +1,78 @@
+#!/usr/bin/env ruby
+
+TEST_REGEX = /TEST_F\([a-zA-Z0-9_]+,\s+([a-zA-Z0-9_]+)\)/
+
+DISABLED_TESTS = %w(
+ test_ex7_10_plain_characters
+ test_ex7_17_flow_mapping_separate_values
+ test_ex7_21_single_pair_implicit_entries
+ test_ex7_2_empty_nodes
+ test_ex8_2_block_indentation_header
+)
+
+class Context
+ attr_accessor :name, :ev, :src
+ def initialize
+ @name = ""
+ @src = ""
+ @ev = []
+ end
+end
+
+class String
+ def snakecase
+ self
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
+ .tr('-', '_')
+ .gsub(/\s/, '_')
+ .gsub(/__+/, '_')
+ .downcase
+ end
+end
+
+ctx = nil
+
+tests = []
+IO.foreach(ARGV[0]) do |line|
+ line.strip!
+ if ctx
+ fail "unexpected TEST_F" if line =~ TEST_REGEX
+ if line =~ /^}/
+ tests << ctx
+ ctx = nil
+ end
+ if line =~ /^EXPECT_CALL/
+ fail 'not end with ;' unless line[-1] == ';'
+ v = line.gsub('(', ' ').gsub(')', ' ').split
+ ctx.ev << v[2]
+ end
+ else
+ next unless line =~ TEST_REGEX
+ name = $1
+ next unless name =~ /^(Ex\d+_\d+)/
+ str = $1.upcase
+ $stderr.puts "found #{name}"
+ ctx = Context.new
+ ctx.name = "test_#{name.snakecase}"
+ ctx.src = str
+ end
+end
+
+# code gen
+tests.each do |t|
+ next if t.ev.size == 0
+ if DISABLED_TESTS.include? t.name
+ puts "#[allow(dead_code)]"
+ else
+ puts "#[test]"
+ end
+ puts "fn #{t.name}() {"
+ puts " let mut v = str_to_test_events(#{t.src}).into_iter();"
+ t.ev.each do |e|
+ puts " assert_next!(v, TestEvent::#{e});"
+ end
+ puts "}"
+ puts
+end
+
diff --git a/third_party/rust/yaml-rust/tests/specs/handler_spec_test.cpp b/third_party/rust/yaml-rust/tests/specs/handler_spec_test.cpp
new file mode 100644
index 0000000000..aa4f7ca238
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specs/handler_spec_test.cpp
@@ -0,0 +1,1532 @@
+#include "handler_test.h"
+#include "specexamples.h" // IWYU pragma: keep
+#include "yaml-cpp/yaml.h" // IWYU pragma: keep
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::_;
+
+#define EXPECT_THROW_PARSER_EXCEPTION(statement, message) \
+ ASSERT_THROW(statement, ParserException); \
+ try { \
+ statement; \
+ } catch (const ParserException& e) { \
+ EXPECT_EQ(e.msg, message); \
+ }
+
+namespace YAML {
+namespace {
+
+typedef HandlerTest HandlerSpecTest;
+
+TEST_F(HandlerSpecTest, Ex2_1_SeqScalars) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_1);
+}
+
+TEST_F(HandlerSpecTest, Ex2_2_MappingScalarsToScalars) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.278"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "rbi"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "147"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_2);
+}
+
+TEST_F(HandlerSpecTest, Ex2_3_MappingScalarsToSequences) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "american"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Boston Red Sox"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Detroit Tigers"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "New York Yankees"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "national"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "New York Mets"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Chicago Cubs"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Atlanta Braves"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_3);
+}
+
+TEST_F(HandlerSpecTest, Ex2_4_SequenceOfMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "name"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.278"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "name"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "63"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.288"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_4);
+}
+
+TEST_F(HandlerSpecTest, Ex2_5_SequenceOfSequences) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "name"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.278"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "63"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.288"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_5);
+}
+
+TEST_F(HandlerSpecTest, Ex2_6_MappingOfMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.278"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "63"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.288"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_6);
+}
+
+TEST_F(HandlerSpecTest, Ex2_7_TwoDocumentsInAStream) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Chicago Cubs"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "St Louis Cardinals"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_7);
+}
+
+TEST_F(HandlerSpecTest, Ex2_8_PlayByPlayFeed) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "time"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "20:03:20"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "player"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "action"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "strike (miss)"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "time"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "20:03:47"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "player"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "action"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "grand slam"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_8);
+}
+
+TEST_F(HandlerSpecTest, Ex2_9_SingleDocumentWithTwoComments) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "rbi"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_9);
+}
+
+TEST_F(HandlerSpecTest, Ex2_10_SimpleAnchor) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 1, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "rbi"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_10);
+}
+
+TEST_F(HandlerSpecTest, Ex2_11_MappingBetweenSequences) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Detroit Tigers"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Chicago cubs"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-07-23"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "New York Yankees"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Atlanta Braves"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-07-02"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-08-12"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-08-14"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_11);
+}
+
+TEST_F(HandlerSpecTest, Ex2_12_CompactNestedMapping) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "item"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Super Hoop"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quantity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "item"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Basketball"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quantity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "4"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "item"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Big Shoes"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quantity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_12);
+}
+
+TEST_F(HandlerSpecTest, Ex2_13_InLiteralsNewlinesArePreserved) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\\//||\\/||\n// || ||__"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_13);
+}
+
+TEST_F(HandlerSpecTest, Ex2_14_InFoldedScalarsNewlinesBecomeSpaces) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Mark McGwire's year was crippled by a knee injury."));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_14);
+}
+
+TEST_F(HandlerSpecTest, Ex2_15_FoldedNewlinesArePreservedForMoreIndentedAndBlankLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_15);
+}
+
+TEST_F(HandlerSpecTest, Ex2_16_IndentationDeterminesScope) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "name"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "accomplishment"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Mark set a major league home run record in 1998.\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "stats"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "65 Home Runs\n0.278 Batting Average\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_16);
+}
+
+TEST_F(HandlerSpecTest, Ex2_17_QuotedScalars) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "unicode"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Sosa did fine.\xE2\x98\xBA"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "control"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\b1998\t1999\t2000\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hex esc"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\x0d\x0a is \r\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "single"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\"Howdy!\" he cried."));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " # Not a 'comment'."));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "tie-fighter"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "|\\-*-/|"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_17);
+}
+
+TEST_F(HandlerSpecTest, Ex2_18_MultiLineFlowScalars) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "plain"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "This unquoted scalar spans many lines."));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "So does this quoted scalar.\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_18);
+}
+
+// TODO: 2.19 - 2.22 schema tags
+
+TEST_F(HandlerSpecTest, Ex2_23_VariousExplicitTags) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "not-date"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "2002-04-28"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "picture"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:binary", 0, "R0lGODlhDAAMAIQAAP//9/X\n17unp5WZmZgAAAOfn515eXv\nPz7Y6OjuDg4J+fn5OTk6enp\n56enmleECcgggoBADs=\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "application specific tag"));
+ EXPECT_CALL(handler, OnScalar(_, "!something", 0, "The semantics of the tag\nabove may be different for\ndifferent documents."));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_23);
+}
+
+TEST_F(HandlerSpecTest, Ex2_24_GlobalTags) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "tag:clarkevans.com,2002:shape", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "tag:clarkevans.com,2002:circle", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "center"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 1, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "x"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "73"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "y"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "129"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "radius"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "7"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "tag:clarkevans.com,2002:line", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "start"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "finish"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "x"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "89"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "y"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "102"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "tag:clarkevans.com,2002:label", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "start"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "color"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0xFFEEBB"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "text"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Pretty vector drawing."));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_24);
+}
+
+TEST_F(HandlerSpecTest, Ex2_25_UnorderedSets) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "tag:yaml.org,2002:set", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_25);
+}
+
+TEST_F(HandlerSpecTest, Ex2_26_OrderedMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "tag:yaml.org,2002:omap", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Mark McGwire"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy Sosa"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "63"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Ken Griffey"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "58"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_26);
+}
+
+TEST_F(HandlerSpecTest, Ex2_27_Invoice) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "tag:clarkevans.com,2002:invoice", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "invoice"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "34843"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "date"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-01-23"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bill-to"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 1, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "given"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Chris"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "family"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Dumars"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "address"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "lines"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "458 Walkman Dr.\nSuite #292\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "city"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Royal Oak"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "state"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "MI"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "postal"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "48046"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "ship-to"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "product"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sku"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "BL394D"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quantity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "4"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "description"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Basketball"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "price"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "450.00"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sku"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "BL4438H"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quantity"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "description"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Super Hoop"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "price"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2392.00"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "tax"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "251.42"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "total"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "4443.52"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "comments"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_27);
+}
+
+TEST_F(HandlerSpecTest, Ex2_28_LogFile) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Time"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-11-23 15:01:42 -5"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "User"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "ed"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Warning"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "This is an error message for the log file"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Time"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-11-23 15:02:31 -5"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "User"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "ed"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Warning"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "A slightly different error message."));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Date"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "2001-11-23 15:03:17 -5"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "User"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "ed"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Fatal"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Unknown variable \"bar\""));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Stack"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "file"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "TopClass.py"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "line"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "23"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "code"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "x = MoreObject(\"345\\n\")\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "file"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "MoreClass.py"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "line"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "58"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "code"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "foo = bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex2_28);
+}
+
+// TODO: 5.1 - 5.2 BOM
+
+TEST_F(HandlerSpecTest, Ex5_3_BlockStructureIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sequence"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "mapping"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sky"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "blue"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sea"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "green"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_3);
+}
+
+TEST_F(HandlerSpecTest, Ex5_4_FlowStructureIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sequence"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "mapping"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sky"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "blue"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sea"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "green"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_4);
+}
+
+
+TEST_F(HandlerSpecTest, Ex5_6_NodePropertyIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "anchored"));
+ EXPECT_CALL(handler, OnScalar(_, "!local", 1, "value"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "alias"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_6);
+}
+
+TEST_F(HandlerSpecTest, Ex5_7_BlockScalarIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "literal"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "some\ntext\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "folded"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "some text\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_7);
+}
+
+TEST_F(HandlerSpecTest, Ex5_8_QuotedScalarIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "single"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "double"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_8);
+}
+
+// TODO: 5.9 directive
+// TODO: 5.10 reserved indicator
+
+TEST_F(HandlerSpecTest, Ex5_11_LineBreakCharacters) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Line break (no glyph)\nLine break (glyphed)\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_11);
+}
+
+TEST_F(HandlerSpecTest, Ex5_12_TabsAndSpaces) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Quoted\t"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "block"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "void main() {\n\tprintf(\"Hello, world!\\n\");\n}"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_12);
+}
+
+TEST_F(HandlerSpecTest, Ex5_13_EscapedCharacters) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Fun with \x5C \x22 \x07 \x08 \x1B \x0C \x0A \x0D \x09 \x0B \x00 \x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9 A A A"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex5_13);
+}
+
+TEST_F(HandlerSpecTest, Ex5_14_InvalidEscapedCharacters) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex5_14), std::string(ErrorMsg::INVALID_ESCAPE) + "c");
+}
+
+TEST_F(HandlerSpecTest, Ex6_1_IndentationSpaces) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Not indented"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "By one space"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "By four\n spaces\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Flow style"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "By two"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Also by two"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Still by two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_1);
+}
+
+TEST_F(HandlerSpecTest, Ex6_2_IndentationIndicators) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "a"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "b"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "c"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "d"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_2);
+}
+
+TEST_F(HandlerSpecTest, Ex6_3_SeparationSpaces) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "baz"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "baz"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_3);
+}
+
+TEST_F(HandlerSpecTest, Ex6_4_LinePrefixes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "plain"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "text lines"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text lines"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "block"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text\n \tlines\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_4);
+}
+
+TEST_F(HandlerSpecTest, Ex6_5_EmptyLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Folding"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Empty line\nas a line feed"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Chomping"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Clipped empty lines\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_5);
+}
+
+TEST_F(HandlerSpecTest, Ex6_6_LineFolding) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "trimmed\n\n\nas space"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_6);
+}
+
+TEST_F(HandlerSpecTest, Ex6_7_BlockFolding) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "foo \n\n\t bar\n\nbaz\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_7);
+}
+
+TEST_F(HandlerSpecTest, Ex6_8_FlowFolding) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " foo\nbar\nbaz "));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_8);
+}
+
+TEST_F(HandlerSpecTest, Ex6_9_SeparatedComment) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_9);
+}
+
+
+TEST_F(HandlerSpecTest, _MultiLineComments) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_11);
+}
+
+TEST_F(HandlerSpecTest, Ex6_12_SeparationSpacesII) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "first"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sammy"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "last"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Sosa"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "hr"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "65"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "avg"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "0.278"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_12);
+}
+
+TEST_F(HandlerSpecTest, Ex6_13_ReservedDirectives) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "foo"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_13);
+}
+
+TEST_F(HandlerSpecTest, Ex6_14_YAMLDirective) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "foo"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_14);
+}
+
+TEST_F(HandlerSpecTest, Ex6_15_InvalidRepeatedYAMLDirective) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex6_15), ErrorMsg::REPEATED_YAML_DIRECTIVE);
+}
+
+TEST_F(HandlerSpecTest, Ex6_16_TagDirective) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "foo"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_16);
+}
+
+TEST_F(HandlerSpecTest, Ex6_17_InvalidRepeatedTagDirective) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex6_17), ErrorMsg::REPEATED_TAG_DIRECTIVE);
+}
+
+TEST_F(HandlerSpecTest, Ex6_18_PrimaryTagHandle) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!foo", 0, "bar"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "tag:example.com,2000:app/foo", 0, "bar"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_18);
+}
+
+TEST_F(HandlerSpecTest, Ex6_19_SecondaryTagHandle) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "tag:example.com,2000:app/int", 0, "1 - 3"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_19);
+}
+
+TEST_F(HandlerSpecTest, Ex6_20_TagHandles) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "tag:example.com,2000:app/foo", 0, "bar"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_20);
+}
+
+TEST_F(HandlerSpecTest, Ex6_21_LocalTagPrefix) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!my-light", 0, "fluorescent"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!my-light", 0, "green"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_21);
+}
+
+TEST_F(HandlerSpecTest, Ex6_22_GlobalTagPrefix) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "tag:example.com,2000:app/foo", 0, "bar"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_22);
+}
+
+TEST_F(HandlerSpecTest, Ex6_23_NodeProperties) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 1, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "bar"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 2, "baz"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_23);
+}
+
+TEST_F(HandlerSpecTest, Ex6_24_VerbatimTags) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "!bar", 0, "baz"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_24);
+}
+
+// TODO: Implement
+TEST_F(HandlerSpecTest, DISABLED_Ex6_25_InvalidVerbatimTags) {
+ Parse(ex6_25);
+ FAIL() << "not implemented yet";
+}
+
+TEST_F(HandlerSpecTest, Ex6_26_TagShorthands) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!local", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "bar"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:example.com,2000:app/tag%21", 0, "baz"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_26);
+}
+
+TEST_F(HandlerSpecTest, Ex6_27a_InvalidTagShorthands) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex6_27a), ErrorMsg::TAG_WITH_NO_SUFFIX);
+}
+
+// TODO: should we reject this one (since !h! is not declared)?
+TEST_F(HandlerSpecTest, DISABLED_Ex6_27b_InvalidTagShorthands) {
+ Parse(ex6_27b);
+ FAIL() << "not implemented yet";
+}
+
+TEST_F(HandlerSpecTest, Ex6_28_NonSpecificTags) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "12"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "12"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "12"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_28);
+}
+
+TEST_F(HandlerSpecTest, Ex6_29_NodeAnchors) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "First occurrence"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 1, "Value"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Second occurrence"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex6_29);
+}
+
+TEST_F(HandlerSpecTest, Ex7_1_AliasNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "First occurrence"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 1, "Foo"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Second occurrence"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Override anchor"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 2, "Bar"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Reuse anchor"));
+ EXPECT_CALL(handler, OnAlias(_, 2));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_1);
+}
+
+TEST_F(HandlerSpecTest, Ex7_2_EmptyNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, ""));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, ""));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_2);
+}
+
+TEST_F(HandlerSpecTest, Ex7_3_CompletelyEmptyNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_3);
+}
+
+TEST_F(HandlerSpecTest, Ex7_4_DoubleQuotedImplicitKeys) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "implicit block key"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "implicit flow key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_4);
+}
+
+TEST_F(HandlerSpecTest, Ex7_5_DoubleQuotedLineBreaks) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "folded to a space,\nto a line feed, or \t \tnon-content"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_5);
+}
+
+TEST_F(HandlerSpecTest, Ex7_6_DoubleQuotedLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " 1st non-empty\n2nd non-empty 3rd non-empty "));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_6);
+}
+
+TEST_F(HandlerSpecTest, Ex7_7_SingleQuotedCharacters) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "here's to \"quotes\""));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_7);
+}
+
+TEST_F(HandlerSpecTest, Ex7_8_SingleQuotedImplicitKeys) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "implicit block key"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "implicit flow key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_8);
+}
+
+TEST_F(HandlerSpecTest, Ex7_9_SingleQuotedLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " 1st non-empty\n2nd non-empty 3rd non-empty "));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_9);
+}
+
+TEST_F(HandlerSpecTest, Ex7_10_PlainCharacters) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "::vector"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, ": - ()"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "Up, up, and away!"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "-123"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "http://example.com/foo#bar"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "::vector"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, ": - ()"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Up, up, and away!"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "-123"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "http://example.com/foo#bar"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_10);
+}
+
+TEST_F(HandlerSpecTest, Ex7_11_PlainImplicitKeys) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "implicit block key"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "implicit flow key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_11);
+}
+
+TEST_F(HandlerSpecTest, Ex7_12_PlainLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "1st non-empty\n2nd non-empty 3rd non-empty"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_12);
+}
+
+TEST_F(HandlerSpecTest, Ex7_13_FlowSequence) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "three"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "four"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_13);
+}
+
+TEST_F(HandlerSpecTest, Ex7_14_FlowSequenceEntries) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "double quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "single quoted"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "plain text"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "nested"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "single"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "pair"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_14);
+}
+
+TEST_F(HandlerSpecTest, Ex7_15_FlowMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "three"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "four"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "five"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "six"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "seven"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "eight"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_15);
+}
+
+TEST_F(HandlerSpecTest, Ex7_16_FlowMappingEntries) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "explicit"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "entry"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "implicit"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "entry"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_16);
+}
+
+TEST_F(HandlerSpecTest, Ex7_17_FlowMappingSeparateValues) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "unquoted"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "separate"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "http://foo.com"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "omitted value"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "omitted key"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_17);
+}
+
+TEST_F(HandlerSpecTest, Ex7_18_FlowMappingAdjacentValues) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "adjacent"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "readable"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "empty"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_18);
+}
+
+TEST_F(HandlerSpecTest, Ex7_19_SinglePairFlowMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_19);
+}
+
+TEST_F(HandlerSpecTest, Ex7_20_SinglePairExplicitEntry) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo bar"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "baz"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_20);
+}
+
+TEST_F(HandlerSpecTest, Ex7_21_SinglePairImplicitEntries) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "YAML"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "separate"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Default));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "empty key entry"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "JSON"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "like"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "adjacent"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_21);
+}
+
+TEST_F(HandlerSpecTest, Ex7_22_InvalidImplicitKeys) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex7_22), ErrorMsg::END_OF_SEQ_FLOW);
+}
+
+TEST_F(HandlerSpecTest, Ex7_23_FlowContent) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "a"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "b"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Flow));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "a"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "b"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "a"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "b"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "c"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_23);
+}
+
+TEST_F(HandlerSpecTest, Ex7_24_FlowNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, "a"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "b"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 1, "c"));
+ EXPECT_CALL(handler, OnAlias(_, 1));
+ EXPECT_CALL(handler, OnScalar(_, "tag:yaml.org,2002:str", 0, ""));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex7_24);
+}
+
+TEST_F(HandlerSpecTest, Ex8_1_BlockScalarHeader) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "literal\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " folded\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "keep\n\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " strip"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_1);
+}
+
+TEST_F(HandlerSpecTest, Ex8_2_BlockIndentationHeader) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "detected\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\n\n# detected\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, " explicit\n"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\t\ndetected\n"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_2);
+}
+
+TEST_F(HandlerSpecTest, Ex8_3a_InvalidBlockScalarIndentationIndicators) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex8_3a), ErrorMsg::END_OF_SEQ);
+}
+
+TEST_F(HandlerSpecTest, Ex8_3b_InvalidBlockScalarIndentationIndicators) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex8_3b), ErrorMsg::END_OF_SEQ);
+}
+
+TEST_F(HandlerSpecTest, Ex8_3c_InvalidBlockScalarIndentationIndicators) {
+ EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse(ex8_3c), ErrorMsg::END_OF_SEQ);
+}
+
+TEST_F(HandlerSpecTest, Ex8_4_ChompingFinalLineBreak) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "strip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "clip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "keep"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "text\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_4);
+}
+
+TEST_F(HandlerSpecTest, DISABLED_Ex8_5_ChompingTrailingLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "strip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "# text"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "clip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "# text\n"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "keep"));
+ // NOTE: I believe this is a bug in the YAML spec -
+ // it should be "# text\n\n"
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "# text\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_5);
+}
+
+TEST_F(HandlerSpecTest, Ex8_6_EmptyScalarChomping) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "strip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, ""));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "clip"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, ""));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "keep"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\n"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_6);
+}
+
+TEST_F(HandlerSpecTest, Ex8_7_LiteralScalar) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "literal\n\ttext\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_7);
+}
+
+TEST_F(HandlerSpecTest, Ex8_8_LiteralContent) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\n\nliteral\n \n\ntext\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_8);
+}
+
+TEST_F(HandlerSpecTest, Ex8_9_FoldedScalar) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "folded text\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_9);
+}
+
+TEST_F(HandlerSpecTest, Ex8_10_FoldedLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_10);
+}
+
+TEST_F(HandlerSpecTest, Ex8_11_MoreIndentedLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_11);
+}
+
+TEST_F(HandlerSpecTest, Ex8_12_EmptySeparationLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_12);
+}
+
+TEST_F(HandlerSpecTest, Ex8_13_FinalEmptyLines) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"));
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_13);
+}
+
+TEST_F(HandlerSpecTest, Ex8_14_BlockSequence) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "block sequence"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "three"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_14);
+}
+
+TEST_F(HandlerSpecTest, Ex8_15_BlockSequenceEntryTypes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "block node\n"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_15);
+}
+
+TEST_F(HandlerSpecTest, Ex8_16_BlockMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "block mapping"));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_16);
+}
+
+TEST_F(HandlerSpecTest, Ex8_17_ExplicitBlockMappingEntries) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "explicit key"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "block key\n"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "one"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "two"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_17);
+}
+
+TEST_F(HandlerSpecTest, Ex8_18_ImplicitBlockMappingEntries) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "plain key"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "in-line value"));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnNull(_, 0));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "quoted key"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "entry"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_18);
+}
+
+TEST_F(HandlerSpecTest, Ex8_19_CompactBlockMappings) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sun"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "yellow"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "earth"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "blue"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "moon"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "white"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_19);
+}
+
+TEST_F(HandlerSpecTest, Ex8_20_BlockNodeTypes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnSequenceStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "flow in block"));
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "Block scalar\n"));
+ EXPECT_CALL(handler, OnMapStart(_, "tag:yaml.org,2002:map", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_20);
+}
+
+TEST_F(HandlerSpecTest, DISABLED_Ex8_21_BlockScalarNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "literal"));
+ // NOTE: I believe this is a bug in the YAML spec
+ // - it should be "value\n"
+ EXPECT_CALL(handler, OnScalar(_, "!", 0, "value"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "folded"));
+ EXPECT_CALL(handler, OnScalar(_, "!foo", 0, "value"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_21);
+}
+
+TEST_F(HandlerSpecTest, Ex8_22_BlockCollectionNodes) {
+ EXPECT_CALL(handler, OnDocumentStart(_));
+ EXPECT_CALL(handler, OnMapStart(_, "?", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "sequence"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "tag:yaml.org,2002:seq", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "entry"));
+ EXPECT_CALL(handler, OnSequenceStart(_, "tag:yaml.org,2002:seq", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "nested"));
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnSequenceEnd());
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "mapping"));
+ EXPECT_CALL(handler, OnMapStart(_, "tag:yaml.org,2002:map", 0, EmitterStyle::Block));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "foo"));
+ EXPECT_CALL(handler, OnScalar(_, "?", 0, "bar"));
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnMapEnd());
+ EXPECT_CALL(handler, OnDocumentEnd());
+ Parse(ex8_22);
+}
+}
+}
diff --git a/third_party/rust/yaml-rust/tests/specs/libyaml_fail-01.yaml b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-01.yaml
new file mode 100644
index 0000000000..5e6c0dc56a
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-01.yaml
@@ -0,0 +1,6 @@
+# Ex 8.18
+plain key: in-line value
+: # Both empty
+"quoted key":
+- entry
+
diff --git a/third_party/rust/yaml-rust/tests/specs/libyaml_fail-02.yaml b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-02.yaml
new file mode 100644
index 0000000000..60074dea2b
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-02.yaml
@@ -0,0 +1,7 @@
+# Ex 7.17
+{
+unqoted : "separate",
+http://foo.com,
+omitted value:,
+: omitted key,
+}
diff --git a/third_party/rust/yaml-rust/tests/specs/libyaml_fail-03.yaml b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-03.yaml
new file mode 100644
index 0000000000..fc821dc73e
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/specs/libyaml_fail-03.yaml
@@ -0,0 +1,5 @@
+# ex 7.2
+{
+ foo : !!str,
+ !!str : bar,
+}
diff --git a/third_party/rust/yaml-rust/tests/test_round_trip.rs b/third_party/rust/yaml-rust/tests/test_round_trip.rs
new file mode 100644
index 0000000000..dc5e85ef39
--- /dev/null
+++ b/third_party/rust/yaml-rust/tests/test_round_trip.rs
@@ -0,0 +1,65 @@
+extern crate yaml_rust;
+
+use yaml_rust::{Yaml, YamlEmitter, YamlLoader};
+
+fn roundtrip(original: &Yaml) {
+ let mut emitted = String::new();
+ YamlEmitter::new(&mut emitted).dump(original).unwrap();
+
+ let documents = YamlLoader::load_from_str(&emitted).unwrap();
+ println!("emitted {}", emitted);
+
+ assert_eq!(documents.len(), 1);
+ assert_eq!(documents[0], *original);
+}
+
+fn double_roundtrip(original: &str) {
+ let parsed = YamlLoader::load_from_str(&original).unwrap();
+
+ let mut serialized = String::new();
+ YamlEmitter::new(&mut serialized).dump(&parsed[0]).unwrap();
+
+ let reparsed = YamlLoader::load_from_str(&serialized).unwrap();
+
+ assert_eq!(parsed, reparsed);
+}
+
+#[test]
+fn test_escape_character() {
+ let y = Yaml::String("\x1b".to_owned());
+ roundtrip(&y);
+}
+
+#[test]
+fn test_colon_in_string() {
+ let y = Yaml::String("x: %".to_owned());
+ roundtrip(&y);
+}
+
+#[test]
+fn test_numberlike_strings() {
+ let docs = [
+ r#"x: "1234""#, r#"x: "01234""#, r#""1234""#,
+ r#""01234""#, r#"" 01234""#, r#""0x1234""#,
+ r#"" 0x1234""#,
+ ];
+
+ for doc in &docs {
+ roundtrip(&Yaml::String(doc.to_string()));
+ double_roundtrip(&doc);
+ }
+}
+
+/// Example from https://github.com/chyh1990/yaml-rust/issues/133
+#[test]
+fn test_issue133() {
+
+ let doc = YamlLoader::load_from_str("\"0x123\"").unwrap().pop().unwrap();
+ assert_eq!(doc, Yaml::String("0x123".to_string()));
+
+ let mut out_str = String::new();
+ YamlEmitter::new(&mut out_str).dump(&doc).unwrap();
+ let doc2 = YamlLoader::load_from_str(&out_str).unwrap().pop().unwrap();
+ assert_eq!(doc, doc2); // This failed because the type has changed to a number now
+
+}