mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-08 01:52:54 +00:00
Edit and add tests
This commit is contained in:
@@ -810,6 +810,8 @@ mod test {
|
||||
schema_builder.add_bytes_field("bytes_not_indexed", STORED);
|
||||
schema_builder.add_json_field("json", TEXT);
|
||||
schema_builder.add_json_field("json_not_indexed", STORED);
|
||||
schema_builder.add_bool_field("bool", INDEXED);
|
||||
schema_builder.add_bool_field("notindexed_bool", STORED);
|
||||
schema_builder.build()
|
||||
}
|
||||
|
||||
@@ -925,6 +927,10 @@ mod test {
|
||||
is_not_indexed_err("notindexed_i64:-234324"),
|
||||
Some(String::from("notindexed_i64"))
|
||||
);
|
||||
assert_eq!(
|
||||
is_not_indexed_err("notindexed_bool:true"),
|
||||
Some(String::from("notindexed_bool"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1006,6 +1012,18 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_bool() {
|
||||
test_parse_query_to_logical_ast_helper(
|
||||
"bool:true",
|
||||
&format!(
|
||||
"{:?}",
|
||||
Term::from_field_bool(Field::from_field_id(16u32), true),
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_bytes_not_indexed() {
|
||||
let error = parse_query_to_logical_ast("bytes_not_indexed:aaa", false).unwrap_err();
|
||||
@@ -1050,6 +1068,15 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_json_field_possibly_a_bool() {
|
||||
test_parse_query_to_logical_ast_helper(
|
||||
"json.titi:true",
|
||||
r#"(Term(type=Json, field=14, path=titi, vtype=Bool, true) Term(type=Json, field=14, path=titi, vtype=Str, "true"))"#,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_json_field_not_indexed() {
|
||||
let error = parse_query_to_logical_ast("json_not_indexed.titi:hello", false).unwrap_err();
|
||||
@@ -1299,6 +1326,17 @@ mod test {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_query_parser_expected_bool() {
|
||||
let query_parser = make_query_parser();
|
||||
assert_matches!(
|
||||
query_parser.parse_query("bool:brie"),
|
||||
Err(QueryParserError::ExpectedBool(_))
|
||||
);
|
||||
assert!(query_parser.parse_query("bool:\"true\"").is_ok());
|
||||
assert!(query_parser.parse_query("bool:\"false\"").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_query_parser_expected_date() {
|
||||
let query_parser = make_query_parser();
|
||||
|
||||
Reference in New Issue
Block a user