Update tests

This commit is contained in:
Mubelotix
2025-08-19 12:20:45 +02:00
committed by Tamo
parent 3133c4a007
commit b4821830bd

View File

@ -1220,38 +1220,34 @@ mod tests {
// georadius have a bad latitude // georadius have a bad latitude
let filter = Filter::from_str("_geoRadius(-100, 150, 10)").unwrap().unwrap(); let filter = Filter::from_str("_geoRadius(-100, 150, 10)").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!( snapshot!(error.to_string(), @r"
error.to_string().starts_with( Bad latitude `-100`. Latitude must be contained between -90 and 90 degrees.
"Bad latitude `-100`. Latitude must be contained between -90 and 90 degrees." 12:16 _geoRadius(-100, 150, 10)
), ");
"{}",
error.to_string()
);
// georadius have a bad latitude // georadius have a bad latitude
let filter = Filter::from_str("_geoRadius(-90.0000001, 150, 10)").unwrap().unwrap(); let filter = Filter::from_str("_geoRadius(-90.0000001, 150, 10)").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees." Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees.
)); 12:23 _geoRadius(-90.0000001, 150, 10)
");
// georadius have a bad longitude // georadius have a bad longitude
let filter = Filter::from_str("_geoRadius(-10, 250, 10)").unwrap().unwrap(); let filter = Filter::from_str("_geoRadius(-10, 250, 10)").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!( snapshot!(error.to_string(), @r"
error.to_string().contains( Bad longitude `250`. Longitude must be contained between -180 and 180 degrees. Hint: try using `-110` instead.
"Bad longitude `250`. Longitude must be contained between -180 and 180 degrees." 17:20 _geoRadius(-10, 250, 10)
), ");
"{}",
error.to_string(),
);
// georadius have a bad longitude // georadius have a bad longitude
let filter = Filter::from_str("_geoRadius(-10, 180.000001, 10)").unwrap().unwrap(); let filter = Filter::from_str("_geoRadius(-10, 180.000001, 10)").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees." Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees. Hint: try using `-179.999999` instead.
)); 17:27 _geoRadius(-10, 180.000001, 10)
");
} }
#[test] #[test]
@ -1274,73 +1270,73 @@ mod tests {
let filter = let filter =
Filter::from_str("_geoBoundingBox([-90.0000001, 150], [30, 10])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([-90.0000001, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!( snapshot!(error.to_string(), @r"
error.to_string().starts_with( Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees.
"Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees." 18:29 _geoBoundingBox([-90.0000001, 150], [30, 10])
), ");
"{}",
error.to_string()
);
// geoboundingbox top left coord have a bad latitude // geoboundingbox top left coord have a bad latitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([90.0000001, 150], [30, 10])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([90.0000001, 150], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!( snapshot!(error.to_string(), @r"
error.to_string().starts_with( Bad latitude `90.0000001`. Latitude must be contained between -90 and 90 degrees.
"Bad latitude `90.0000001`. Latitude must be contained between -90 and 90 degrees." 18:28 _geoBoundingBox([90.0000001, 150], [30, 10])
), ");
"{}",
error.to_string()
);
// geoboundingbox bottom right coord have a bad latitude // geoboundingbox bottom right coord have a bad latitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([30, 10], [-90.0000001, 150])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([30, 10], [-90.0000001, 150])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees." Bad latitude `-90.0000001`. Latitude must be contained between -90 and 90 degrees.
)); 28:39 _geoBoundingBox([30, 10], [-90.0000001, 150])
");
// geoboundingbox bottom right coord have a bad latitude // geoboundingbox bottom right coord have a bad latitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([30, 10], [90.0000001, 150])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([30, 10], [90.0000001, 150])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad latitude `90.0000001`. Latitude must be contained between -90 and 90 degrees." Bad latitude `90.0000001`. Latitude must be contained between -90 and 90 degrees.
)); 28:38 _geoBoundingBox([30, 10], [90.0000001, 150])
");
// geoboundingbox top left coord have a bad longitude // geoboundingbox top left coord have a bad longitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([-10, 180.000001], [30, 10])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([-10, 180.000001], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees." Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees. Hint: try using `-179.999999` instead.
)); 23:33 _geoBoundingBox([-10, 180.000001], [30, 10])
");
// geoboundingbox top left coord have a bad longitude // geoboundingbox top left coord have a bad longitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([-10, -180.000001], [30, 10])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([-10, -180.000001], [30, 10])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees." Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees. Hint: try using `179.999999` instead.
)); 23:34 _geoBoundingBox([-10, -180.000001], [30, 10])
");
// geoboundingbox bottom right coord have a bad longitude // geoboundingbox bottom right coord have a bad longitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([30, 10], [-10, -180.000001])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([30, 10], [-10, -180.000001])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees." Bad longitude `-180.000001`. Longitude must be contained between -180 and 180 degrees. Hint: try using `179.999999` instead.
)); 33:44 _geoBoundingBox([30, 10], [-10, -180.000001])
");
// geoboundingbox bottom right coord have a bad longitude // geoboundingbox bottom right coord have a bad longitude
let filter = let filter =
Filter::from_str("_geoBoundingBox([30, 10], [-10, 180.000001])").unwrap().unwrap(); Filter::from_str("_geoBoundingBox([30, 10], [-10, 180.000001])").unwrap().unwrap();
let error = filter.evaluate(&rtxn, &index).unwrap_err(); let error = filter.evaluate(&rtxn, &index).unwrap_err();
assert!(error.to_string().contains( snapshot!(error.to_string(), @r"
"Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees." Bad longitude `180.000001`. Longitude must be contained between -180 and 180 degrees. Hint: try using `-179.999999` instead.
)); 33:43 _geoBoundingBox([30, 10], [-10, 180.000001])
");
} }
#[test] #[test]