diff options
author | Dan Saadati <dsaadati@google.com> | 2021-12-28 13:43:34 -0800 |
---|---|---|
committer | Dan Saadati <dsaadati@google.com> | 2021-12-28 15:12:47 -0800 |
commit | beff93fe1f5165aeeb871d9711963aa1846299ae (patch) | |
tree | 247c43adc7dc69fb846fd92c2da96654fbe818ea /icing/index/main/main-index_test.cc | |
parent | da1b8986e7c873efa45529b8adc4a32490eb9c3c (diff) | |
download | icing-beff93fe1f5165aeeb871d9711963aa1846299ae.tar.gz |
Sync from upstream.
Descriptions:
================
Normalize Tokens by Token type when retrieving snippets
================
Rename max_window_bytes to max_window_utf32_length,
Delete the max_tokens_per_doc field in IcingSearchEngineOptions.
================
Handle suggestion namespace ownership.
================
Fix OkStatus() is not a valid argument to StatusOr in
Main_index.RetrieveMoreHits.
================
Allow advancing when current indices are negative in CharacterIterator
================
Adds support for verbatim tokenization and indexing in IcingLib
================
Renames TokenizerIterator Reset functions
================
Add term_match_type to SuggestionSpec proto
================
Unify the C++ proto enum style
================
Allow zero property weights in IcingLib
================
Bug: 204333391
Bug: 152934343
Bug: 205209589
Bug: 206147728
Bug: 209993976
Change-Id: Id94a377fd37c5eb7ebc3d7547cf8ff0ad4152620
Diffstat (limited to 'icing/index/main/main-index_test.cc')
-rw-r--r-- | icing/index/main/main-index_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/icing/index/main/main-index_test.cc b/icing/index/main/main-index_test.cc index 74139be..fa83d68 100644 --- a/icing/index/main/main-index_test.cc +++ b/icing/index/main/main-index_test.cc @@ -162,6 +162,34 @@ TEST_F(MainIndexTest, MainIndexGetAccessorForPrefixReturnsValidAccessor) { EXPECT_THAT(main_index->GetAccessorForPrefixTerm("foo"), IsOk()); } +TEST_F(MainIndexTest, MainIndexGetAccessorForPrefixReturnsNotFound) { + // 1. Index one doc in the Lite Index: + // - Doc0 {"foot" is_in_prefix_section=false} + ICING_ASSERT_OK_AND_ASSIGN( + uint32_t tvi, + lite_index_->InsertTerm("foot", TermMatchType::EXACT_ONLY, kNamespace0)); + ICING_ASSERT_OK_AND_ASSIGN(uint32_t foot_term_id, + term_id_codec_->EncodeTvi(tvi, TviType::LITE)); + + Hit doc0_hit(/*section_id=*/0, /*document_id=*/0, Hit::kDefaultTermFrequency, + /*is_in_prefix_section=*/false); + ICING_ASSERT_OK(lite_index_->AddHit(foot_term_id, doc0_hit)); + + // 2. Create the main index. It should have no entries in its lexicon. + std::string main_index_file_name = index_dir_ + "/test_file.idx.index"; + ICING_ASSERT_OK_AND_ASSIGN( + std::unique_ptr<MainIndex> main_index, + MainIndex::Create(main_index_file_name, &filesystem_, + &icing_filesystem_)); + + // 3. Merge the index. The main index should return not found when we search + // prefix contain "foo". + ICING_ASSERT_OK(Merge(*lite_index_, *term_id_codec_, main_index.get())); + // GetAccessorForPrefixTerm should return a valid accessor for "foo". + EXPECT_THAT(main_index->GetAccessorForPrefixTerm("foo"), + StatusIs(libtextclassifier3::StatusCode::NOT_FOUND)); +} + TEST_F(MainIndexTest, MainIndexGetAccessorForExactTermNotFound) { // Create the main index. It should have no entries in its lexicon. std::string main_index_file_name = index_dir_ + "/test_file.idx.index"; |