diff options
Diffstat (limited to 'icing/query/suggestion-processor_test.cc')
-rw-r--r-- | icing/query/suggestion-processor_test.cc | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/icing/query/suggestion-processor_test.cc b/icing/query/suggestion-processor_test.cc index 4937f39..b1336b3 100644 --- a/icing/query/suggestion-processor_test.cc +++ b/icing/query/suggestion-processor_test.cc @@ -200,7 +200,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_And) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("bar foo")); } @@ -249,7 +250,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_AndNary) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("bar cat foo")); } @@ -301,7 +303,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_Or) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("bar OR cat fo", "bar OR cat foo")); } @@ -363,7 +366,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_OrNary) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); // "fo" in document1, "foo" in document2 and "fool" in document3 could match. EXPECT_THAT( RetrieveSuggestionsText(terms), @@ -417,7 +421,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_NormalizedTerm) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); // The term is normalized. EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("bar foo", "bar fool")); @@ -425,7 +430,8 @@ TEST_F(SuggestionProcessorTest, MultipleTermsTest_NormalizedTerm) { // Search for "bar AND ḞÖ" suggestion_spec.set_prefix("bar ḞÖ"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); // The term is normalized. EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("bar foo", "bar fool")); @@ -462,7 +468,8 @@ TEST_F(SuggestionProcessorTest, NonExistentPrefixTest) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(terms, IsEmpty()); } @@ -497,7 +504,8 @@ TEST_F(SuggestionProcessorTest, PrefixTrailingSpaceTest) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(terms, IsEmpty()); } @@ -531,22 +539,26 @@ TEST_F(SuggestionProcessorTest, NormalizePrefixTest) { TermMatchType::PREFIX); ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("foo")); suggestion_spec.set_prefix("fO"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("foo")); suggestion_spec.set_prefix("Fo"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("foo")); suggestion_spec.set_prefix("FO"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(RetrieveSuggestionsText(terms), UnorderedElementsAre("foo")); } @@ -581,17 +593,20 @@ TEST_F(SuggestionProcessorTest, ParenthesesOperatorPrefixTest) { ICING_ASSERT_OK_AND_ASSIGN( std::vector<TermMetadata> terms, - suggestion_processor_->QuerySuggestions(suggestion_spec)); + suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(terms, IsEmpty()); suggestion_spec.set_prefix("[f]"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(terms, IsEmpty()); suggestion_spec.set_prefix("(f)"); ICING_ASSERT_OK_AND_ASSIGN( - terms, suggestion_processor_->QuerySuggestions(suggestion_spec)); + terms, suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds())); EXPECT_THAT(terms, IsEmpty()); } @@ -624,7 +639,8 @@ TEST_F(SuggestionProcessorTest, OtherSpecialPrefixTest) { suggestion_spec.mutable_scoring_spec()->set_scoring_match_type( TermMatchType::PREFIX); - auto terms_or = suggestion_processor_->QuerySuggestions(suggestion_spec); + auto terms_or = suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds()); if (SearchSpecProto::default_instance().search_type() == SearchSpecProto::SearchType::ICING_RAW_QUERY) { ICING_ASSERT_OK_AND_ASSIGN(std::vector<TermMetadata> terms, terms_or); @@ -638,12 +654,14 @@ TEST_F(SuggestionProcessorTest, OtherSpecialPrefixTest) { // within a TEXT token (rather than a MINUS token) when surrounded on both // sides by TEXT rather than just preceded by TEXT. suggestion_spec.set_prefix("f-"); - terms_or = suggestion_processor_->QuerySuggestions(suggestion_spec); + terms_or = suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds()); ICING_ASSERT_OK_AND_ASSIGN(std::vector<TermMetadata> terms, terms_or); EXPECT_THAT(terms, IsEmpty()); suggestion_spec.set_prefix("f OR"); - terms_or = suggestion_processor_->QuerySuggestions(suggestion_spec); + terms_or = suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds()); if (SearchSpecProto::default_instance().search_type() == SearchSpecProto::SearchType::ICING_RAW_QUERY) { ICING_ASSERT_OK_AND_ASSIGN(std::vector<TermMetadata> terms, terms_or); @@ -683,7 +701,8 @@ TEST_F(SuggestionProcessorTest, InvalidPrefixTest) { suggestion_spec.mutable_scoring_spec()->set_scoring_match_type( TermMatchType::PREFIX); - auto terms_or = suggestion_processor_->QuerySuggestions(suggestion_spec); + auto terms_or = suggestion_processor_->QuerySuggestions( + suggestion_spec, fake_clock_.GetSystemTimeMilliseconds()); if (SearchSpecProto::default_instance().search_type() == SearchSpecProto::SearchType::ICING_RAW_QUERY) { ICING_ASSERT_OK_AND_ASSIGN(std::vector<TermMetadata> terms, terms_or); |