diff --git a/crates/json-pawarser/src/grammar/object.rs b/crates/json-pawarser/src/grammar/object.rs index d72dcdc..c1341fd 100644 --- a/crates/json-pawarser/src/grammar/object.rs +++ b/crates/json-pawarser/src/grammar/object.rs @@ -61,3 +61,17 @@ fn member(p: &mut Parser) -> Option { ) } } + +#[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 ":"; } } }"# + } + } +}