Start json test
This commit is contained in:
parent
8002b83a86
commit
22d0aa73de
20
src/lib.rs
20
src/lib.rs
@ -258,4 +258,24 @@ mod tests {
|
|||||||
let p = choice(literal("gnostika").to(1), one_or_more(literal(" ")).to(2));
|
let p = choice(literal("gnostika").to(1), one_or_more(literal(" ")).to(2));
|
||||||
assert_eq!(p.parse("gnostika twentynine"), Ok((1, " twentynine")));
|
assert_eq!(p.parse("gnostika twentynine"), Ok((1, " twentynine")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JSON BNF
|
||||||
|
* <JSON> ::= <value>
|
||||||
|
<value> ::= <object> | <array> | <boolean> | <string> | <number> | <null>
|
||||||
|
<array> ::= "[" [<value>] {"," <value>}* "]"
|
||||||
|
<object> ::= "{" [<property>] {"," <property>}* "}"
|
||||||
|
<property> ::= <string> ":" <value>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#[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", "")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user