mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2025-12-23 02:29:57 +00:00
unit test parse_query_lenient
This commit is contained in:
@@ -29,10 +29,10 @@ pub fn parse_query_lenient(query: &str) -> (UserInputAst, Vec<LenientError>) {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::parse_query;
|
||||
use crate::{parse_query, parse_query_lenient};
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
fn test_parse_query_serialization() {
|
||||
let ast = parse_query("title:hello").unwrap();
|
||||
let json = serde_json::to_string(&ast).unwrap();
|
||||
assert_eq!(json, r#"{"Leaf":{"Literal":{"field_name":"title","phrase":"hello","delimiter":"None","slop":0,"prefix":false}}}"#);
|
||||
@@ -42,4 +42,10 @@ mod tests {
|
||||
fn test_parse_query_wrong_query() {
|
||||
assert!(parse_query("title:").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_query_lenient_wrong_query() {
|
||||
let (_, errors) = parse_query_lenient("title:");
|
||||
assert!(errors.len() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,11 +323,4 @@ mod tests {
|
||||
let json = serde_json::to_string(&ast).unwrap();
|
||||
assert_eq!(json, r#"{"Leaf":{"Range":{"field":"price","lower":{"Inclusive":"10"},"upper":{"Exclusive":"100"}}}}"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_all_leaf_deserialization() {
|
||||
let json = r#"{"Leaf":"All"}"#;
|
||||
let ast: UserInputAst = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(ast, UserInputAst::Leaf(Box::new(UserInputLeaf::All)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user