#[cfg(test)]
mod tests {
use crate::test_helpers::{assert_parse_error, parse_yaml};
#[test]
fn test_9mag_leading_comma_in_sequence() {
let yaml = b"---\n[ , a, b, c ]\n";
assert_parse_error(yaml, "comma");
}
#[test]
fn test_ctn5_double_comma_in_sequence() {
let yaml = b"---\n[ a, b, c, , ]\n";
let result = std::panic::catch_unwind(|| assert_parse_error(yaml, "comma"));
if result.is_err() {
assert_parse_error(yaml, "consecutive");
}
}
#[test]
fn test_cvw2_comment_without_space_after_comma() {
let yaml = b"---\n[ a, b, c,#invalid\n]\n";
assert_parse_error(yaml, "comment");
}
#[test]
fn test_9jba_comment_without_space_after_bracket() {
let yaml = b"---\n[ a, b, c, ]#invalid\n";
assert_parse_error(yaml, "]");
}
#[test]
fn test_5c5m_valid_trailing_comma() {
let yaml = b"- { one : two , three: four , }\n- {five: six,seven : eight}";
let result = parse_yaml(yaml);
assert!(
matches!(result, crate::Node::Documents(_)),
"Should accept trailing comma in flow mapping"
);
}
#[test]
fn test_valid_sequence_trailing_comma() {
let yaml = b"[1, 2, 3,]";
let result = parse_yaml(yaml);
assert!(
matches!(result, crate::Node::Documents(_)),
"Should accept trailing comma in flow sequence"
);
}
}