From ef1a9f502936b1f38968bdca3ef06ee1481665b8 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 30 Oct 2024 10:57:52 +0100 Subject: [PATCH] json-pawarser: test grammar::member --- crates/json-pawarser/src/grammar/object.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 ":"; } } }"# + } + } +}