From f1da623af3edbf0e5f5ffee9e00f4a7db0babbf0 Mon Sep 17 00:00:00 2001 From: Samyak S Sarnayak Date: Thu, 20 Oct 2022 18:41:37 +0530 Subject: [PATCH] Add test for phrase search with stop words and all criteria at once Moved the actual test into a separate function used by both the existing test and the new test. --- milli/tests/search/phrase_search.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/milli/tests/search/phrase_search.rs b/milli/tests/search/phrase_search.rs index 313833543..e255927d8 100644 --- a/milli/tests/search/phrase_search.rs +++ b/milli/tests/search/phrase_search.rs @@ -1,5 +1,6 @@ +use crate::search::Criterion::{Attribute, Exactness, Proximity}; use milli::update::{IndexerConfig, Settings}; -use milli::{Index, Search, TermsMatchingStrategy}; +use milli::{Criterion, Index, Search, TermsMatchingStrategy}; fn set_stop_words(index: &Index, stop_words: &[&str]) { let mut wtxn = index.write_txn().unwrap(); @@ -12,9 +13,7 @@ fn set_stop_words(index: &Index, stop_words: &[&str]) { wtxn.commit().unwrap(); } -#[test] -fn test_phrase_search_with_stop_words() { - let criteria = []; +fn test_phrase_search_with_stop_words_given_criteria(criteria: &[Criterion]) { let index = super::setup_search_index_with_criteria(&criteria); // Add stop_words @@ -42,3 +41,15 @@ fn test_phrase_search_with_stop_words() { let result = search.execute().unwrap(); assert_eq!(result.documents_ids.len(), 0); } + +#[test] +fn test_phrase_search_with_stop_words_no_criteria() { + let criteria = []; + test_phrase_search_with_stop_words_given_criteria(&criteria); +} + +#[test] +fn test_phrase_search_with_stop_words_all_criteria() { + let criteria = [Proximity, Attribute, Exactness]; + test_phrase_search_with_stop_words_given_criteria(&criteria); +}