json-pawarser: test grammar::member

This commit is contained in:
Schrottkatze 2024-10-30 10:57:52 +01:00
parent 662cb8ba0e
commit ef1a9f5029
No known key found for this signature in database

View file

@ -61,3 +61,17 @@ fn member(p: &mut Parser) -> Option<CompletedMarker> {
)
}
}
#[cfg(test)]
mod tests {
use crate::grammar::{object::member, test_utils::gen_checks};
#[test]
fn member_basic() {
gen_checks! {member;
r#""a": "b""# => r#"ROOT { MEMBER { MEMBER_NAME { STRING "\"a\""; } COLON ":"; WHITESPACE " "; MEMBER_VALUE { STRING "\"b\""; } } }"#,
r#""a": 42"# => r#"ROOT { MEMBER { MEMBER_NAME { STRING "\"a\""; } COLON ":"; WHITESPACE " "; MEMBER_VALUE { NUMBER "42"; } } }"#,
r#""a":"# => r#"ROOT { MEMBER { PARSE_ERR: MemberMissingValue { MEMBER_NAME { STRING "\"a\""; } COLON ":"; } } }"#
}
}
}