From 92c0a2cdc1d5c6afeef84c409422af2152787cee Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Thu, 22 Jul 2021 17:14:44 +0200 Subject: [PATCH] Add a test that triggers a panic when indexing zeroes --- milli/src/update/index_documents/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 9ac05fe1a..cd48175f7 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -1380,4 +1380,26 @@ mod tests { wtxn.commit().unwrap(); } + + #[test] + fn index_documents_with_zeroes() { + let path = tempfile::tempdir().unwrap(); + let mut options = EnvOpenOptions::new(); + options.map_size(10 * 1024 * 1024); // 10 MB + let index = Index::new(options, &path).unwrap(); + + let mut wtxn = index.write_txn().unwrap(); + let content = r#"#id,title,au{hor,genre,price$ +2,"Prideand Prejudice","Jane Austin","romance",3.5$ +456,"Le Petit Prince","Antoine de Saint-Exupéry","adventure",10.0$ +1,Wonderland","Lewis Carroll","fantasy",25.99$ +4,"Harry Potter ing","fantasy\0lood Prince","J. K. Rowling","fantasy\0, +"#; + + let mut builder = IndexDocuments::new(&mut wtxn, &index, 0); + builder.update_format(UpdateFormat::Csv); + builder.execute(content.as_bytes(), |_, _| ()).unwrap(); + + wtxn.commit().unwrap(); + } }