json-parser/tests/error_tests.rs
Timothy Warren 05e6e53cfb
All checks were successful
timw4mail/json-parser/master This commit looks good
Add integration tests
2020-02-12 11:22:16 -05:00

31 lines
634 B
Rust

use naive_json_parser::*;
#[test]
fn sanity_check() {
let res = JSON::parse(r#"-q"#);
assert_eq!(
res,
Err(ParseError::ExpectedDigit(String::from(
"Expected a digit, received 'q' after numeric '-'"
)))
);
}
#[test]
fn bad_object_trailing_comma() {
let res = JSON::parse("{,}");
assert_eq!(
res,
Err(ParseError::ExpectedObjectKey(String::from(
"Expected an object key. Does the object have a trailing comma?"
)))
);
}
#[test]
fn bad_json() {
let res = JSON::parse(r#"5eq"#);
assert!(res.is_err());
println!("{:#?}", res);
}