caio.co/de/cantine

Ensure it's hard to cause an Err() with this parser

Id
6b7c1ef88ae71181c7fe712909fa579ceae3d516
Author
Caio
Commit time
2020-03-06T18:15:20+01:00

Modified tique/Cargo.toml

@@ -19,3 +19,6
[dependencies]
tantivy = "0.12"
nom = { version = "5", optional = true }
+
+[dev-dependencies]
+quickcheck = "0.9"

Modified tique/src/queryparser/parser.rs

@@ -314,4 +314,16
))
);
}
+
+ use quickcheck::QuickCheck;
+
+ #[test]
+ fn can_handle_arbitrary_input() {
+ fn prop(input: String) -> bool {
+ parse_query(input.as_str(), &false).is_ok()
+ && parse_query(input.as_str(), &true).is_ok()
+ }
+
+ QuickCheck::new().quickcheck(prop as fn(String) -> bool);
+ }
}