Add parser tests for complex Record IDs
This commit is contained in:
parent
eab862b9e4
commit
e4a7ef4afe
1 changed files with 38 additions and 0 deletions
|
@ -115,6 +115,9 @@ fn thing_double(i: &str) -> IResult<&str, Thing> {
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::sql::array::Array;
|
||||||
|
use crate::sql::object::Object;
|
||||||
|
use crate::sql::value::Value;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn thing_normal() {
|
fn thing_normal() {
|
||||||
|
@ -163,4 +166,39 @@ mod tests {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn thing_object() {
|
||||||
|
let sql = "test:{ location: 'GBR', year: 2022 }";
|
||||||
|
let res = thing(sql);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
let out = res.unwrap().1;
|
||||||
|
assert_eq!(r#"test:{ location: "GBR", year: 2022 }"#, format!("{}", out));
|
||||||
|
assert_eq!(
|
||||||
|
out,
|
||||||
|
Thing {
|
||||||
|
tb: String::from("test"),
|
||||||
|
id: Id::Object(Object::from(map! {
|
||||||
|
"location".to_string() => Value::from("GBR"),
|
||||||
|
"year".to_string() => Value::from(2022),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn thing_array() {
|
||||||
|
let sql = "test:['GBR', 2022]";
|
||||||
|
let res = thing(sql);
|
||||||
|
assert!(res.is_ok());
|
||||||
|
let out = res.unwrap().1;
|
||||||
|
assert_eq!(r#"test:["GBR", 2022]"#, format!("{}", out));
|
||||||
|
assert_eq!(
|
||||||
|
out,
|
||||||
|
Thing {
|
||||||
|
tb: String::from("test"),
|
||||||
|
id: Id::Array(Array::from(vec![Value::from("GBR"), Value::from(2022)])),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue