From 22d0aa73de1d5336c6fad5fbb0b37bddb48c4714 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 16 Oct 2022 01:36:20 -0700 Subject: [PATCH] Start json test --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 9e55347..ec1ccf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,4 +258,24 @@ mod tests { let p = choice(literal("gnostika").to(1), one_or_more(literal(" ")).to(2)); assert_eq!(p.parse("gnostika twentynine"), Ok((1, " twentynine"))); } + + /* + * JSON BNF + * ::= + ::= | | | | | + ::= "[" [] {"," }* "]" + ::= "{" [] {"," }* "}" + ::= ":" + */ + + #[test] + fn parse_json() { + let json_null = literal("null"); + let json_true = literal("true"); + let json_false = literal("false"); + + let json_value = choice(json_null, choice(json_true, json_false)); + + assert_matches!(json_value.parse("true"), Ok(("true", ""))); + } }