| Index: chrome/browser/history/in_memory_url_index_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/history/in_memory_url_index_unittest.cc (revision 105497)
|
| +++ chrome/browser/history/in_memory_url_index_unittest.cc (working copy)
|
| @@ -2,24 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include <stdio.h>
|
| -
|
| #include <fstream>
|
| -#include <string>
|
| -#include <vector>
|
|
|
| #include "base/file_path.h"
|
| #include "base/file_util.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| #include "base/path_service.h"
|
| +#include "base/string16.h"
|
| #include "base/string_util.h"
|
| -#include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/history/in_memory_database.h"
|
| #include "chrome/browser/history/in_memory_url_index.h"
|
| +#include "chrome/browser/history/in_memory_url_index_types.h"
|
| #include "chrome/common/chrome_paths.h"
|
| -#include "sql/connection.h"
|
| -#include "sql/statement.h"
|
| #include "sql/transaction.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -59,9 +53,8 @@
|
| int typed_count);
|
|
|
| // Convenience functions for easily creating vectors of search terms.
|
| - InMemoryURLIndex::String16Vector Make1Term(const char* term) const;
|
| - InMemoryURLIndex::String16Vector Make2Terms(const char* term_1,
|
| - const char* term_2) const;
|
| + String16Vector Make1Term(const char* term) const;
|
| + String16Vector Make2Terms(const char* term_1, const char* term_2) const;
|
|
|
| // Validates that the given |term| is contained in |cache| and that it is
|
| // marked as in-use.
|
| @@ -145,17 +138,15 @@
|
| return row;
|
| }
|
|
|
| -InMemoryURLIndex::String16Vector InMemoryURLIndexTest::Make1Term(
|
| - const char* term) const {
|
| - InMemoryURLIndex::String16Vector terms;
|
| +String16Vector InMemoryURLIndexTest::Make1Term(const char* term) const {
|
| + String16Vector terms;
|
| terms.push_back(UTF8ToUTF16(term));
|
| return terms;
|
| }
|
|
|
| -InMemoryURLIndex::String16Vector InMemoryURLIndexTest::Make2Terms(
|
| - const char* term_1,
|
| - const char* term_2) const {
|
| - InMemoryURLIndex::String16Vector terms;
|
| +String16Vector InMemoryURLIndexTest::Make2Terms(const char* term_1,
|
| + const char* term_2) const {
|
| + String16Vector terms;
|
| terms.push_back(UTF8ToUTF16(term_1));
|
| terms.push_back(UTF8ToUTF16(term_2));
|
| return terms;
|
| @@ -173,6 +164,27 @@
|
| << "Cache item '" << term << "' should be marked as being in use.";
|
| }
|
|
|
| +// Helper function which compares two maps for equivalence. The maps' values
|
| +// are associative containers and their contents are compared as well.
|
| +template<typename T>
|
| +void ExpectMapOfContainersIdentical(const T& expected, const T& actual) {
|
| + ASSERT_EQ(expected.size(), actual.size());
|
| + for (typename T::const_iterator expected_iter = expected.begin();
|
| + expected_iter != expected.end(); ++expected_iter) {
|
| + typename T::const_iterator actual_iter = actual.find(expected_iter->first);
|
| + ASSERT_NE(actual.end(), actual_iter);
|
| + typename T::mapped_type const& expected_values(expected_iter->second);
|
| + typename T::mapped_type const& actual_values(actual_iter->second);
|
| + ASSERT_EQ(expected_values.size(), actual_values.size());
|
| + for (typename T::mapped_type::const_iterator set_iter =
|
| + expected_values.begin(); set_iter != expected_values.end(); ++set_iter)
|
| + EXPECT_EQ(actual_values.count(*set_iter),
|
| + expected_values.count(*set_iter));
|
| + }
|
| +}
|
| +
|
| +//------------------------------------------------------------------------------
|
| +
|
| class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest {
|
| protected:
|
| FilePath::StringType TestDBName() const;
|
| @@ -203,7 +215,8 @@
|
| }
|
|
|
| TEST_F(InMemoryURLIndexTest, Construction) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| EXPECT_TRUE(url_index_.get());
|
| }
|
|
|
| @@ -217,16 +230,17 @@
|
| EXPECT_EQ(1U, row_count);
|
| url_index_.reset(new InMemoryURLIndex);
|
| url_index_->Init(this, "en,ja,hi,zh");
|
| - EXPECT_EQ(1, url_index_->history_item_count_);
|
| + URLIndexPrivateData& private_data(*(url_index_->private_data_));
|
|
|
| // history_info_map_ should have the same number of items as were filtered.
|
| - EXPECT_EQ(1U, url_index_->history_info_map_.size());
|
| - EXPECT_EQ(35U, url_index_->char_word_map_.size());
|
| - EXPECT_EQ(17U, url_index_->word_map_.size());
|
| + EXPECT_EQ(1U, private_data.history_info_map_.size());
|
| + EXPECT_EQ(35U, private_data.char_word_map_.size());
|
| + EXPECT_EQ(17U, private_data.word_map_.size());
|
| }
|
|
|
| TEST_F(InMemoryURLIndexTest, Retrieval) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| url_index_->Init(this, "en,ja,hi,zh");
|
| // The term will be lowercased by the search.
|
|
|
| @@ -259,7 +273,7 @@
|
| matches[0].url_info.title());
|
|
|
| // Search which should result in very poor result.
|
| - InMemoryURLIndex::String16Vector terms;
|
| + String16Vector terms;
|
| terms.push_back(ASCIIToUTF16("z"));
|
| terms.push_back(ASCIIToUTF16("y"));
|
| terms.push_back(ASCIIToUTF16("x"));
|
| @@ -279,7 +293,8 @@
|
| }
|
|
|
| TEST_F(ExpandedInMemoryURLIndexTest, ShortCircuit) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| url_index_->Init(this, "en,ja,hi,zh");
|
|
|
| // A search for 'w' should short-circuit and not return any matches.
|
| @@ -296,8 +311,8 @@
|
| url_index_.reset(new InMemoryURLIndex());
|
| url_index_->Init(this, "en,ja,hi,zh");
|
| // Signal if someone has changed the test DB.
|
| - EXPECT_EQ(27U, url_index_->history_info_map_.size());
|
| - InMemoryURLIndex::String16Vector terms;
|
| + EXPECT_EQ(27U, url_index_->private_data_->history_info_map_.size());
|
| + String16Vector terms;
|
|
|
| // Ensure title is being searched.
|
| terms.push_back(ASCIIToUTF16("MORTGAGE"));
|
| @@ -345,101 +360,6 @@
|
| EXPECT_EQ(28, matches[0].url_info.id());
|
| }
|
|
|
| -TEST_F(InMemoryURLIndexTest, StaticFunctions) {
|
| - // Test WordVectorFromString16
|
| - string16 string_a(ASCIIToUTF16("http://www.google.com/ frammy the brammy"));
|
| - InMemoryURLIndex::String16Vector string_vec =
|
| - InMemoryURLIndex::WordVectorFromString16(string_a, false);
|
| - ASSERT_EQ(7U, string_vec.size());
|
| - // See if we got the words we expected.
|
| - EXPECT_EQ(UTF8ToUTF16("http"), string_vec[0]);
|
| - EXPECT_EQ(UTF8ToUTF16("www"), string_vec[1]);
|
| - EXPECT_EQ(UTF8ToUTF16("google"), string_vec[2]);
|
| - EXPECT_EQ(UTF8ToUTF16("com"), string_vec[3]);
|
| - EXPECT_EQ(UTF8ToUTF16("frammy"), string_vec[4]);
|
| - EXPECT_EQ(UTF8ToUTF16("the"), string_vec[5]);
|
| - EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[6]);
|
| -
|
| - string_vec = InMemoryURLIndex::WordVectorFromString16(string_a, true);
|
| - ASSERT_EQ(5U, string_vec.size());
|
| - EXPECT_EQ(UTF8ToUTF16("http://"), string_vec[0]);
|
| - EXPECT_EQ(UTF8ToUTF16("www.google.com/"), string_vec[1]);
|
| - EXPECT_EQ(UTF8ToUTF16("frammy"), string_vec[2]);
|
| - EXPECT_EQ(UTF8ToUTF16("the"), string_vec[3]);
|
| - EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[4]);
|
| -
|
| - // Test WordSetFromString16
|
| - string16 string_b(ASCIIToUTF16(
|
| - "http://web.google.com/search Google Web Search"));
|
| - InMemoryURLIndex::String16Set string_set =
|
| - InMemoryURLIndex::WordSetFromString16(string_b);
|
| - EXPECT_EQ(5U, string_set.size());
|
| - // See if we got the words we expected.
|
| - EXPECT_TRUE(string_set.find(UTF8ToUTF16("com")) != string_set.end());
|
| - EXPECT_TRUE(string_set.find(UTF8ToUTF16("google")) != string_set.end());
|
| - EXPECT_TRUE(string_set.find(UTF8ToUTF16("http")) != string_set.end());
|
| - EXPECT_TRUE(string_set.find(UTF8ToUTF16("search")) != string_set.end());
|
| - EXPECT_TRUE(string_set.find(UTF8ToUTF16("web")) != string_set.end());
|
| -
|
| - // Test SortAndDeoverlap
|
| - TermMatches matches_a;
|
| - matches_a.push_back(TermMatch(1, 13, 10));
|
| - matches_a.push_back(TermMatch(2, 23, 10));
|
| - matches_a.push_back(TermMatch(3, 3, 10));
|
| - matches_a.push_back(TermMatch(4, 40, 5));
|
| - TermMatches matches_b = InMemoryURLIndex::SortAndDeoverlap(matches_a);
|
| - // Nothing should have been eliminated.
|
| - EXPECT_EQ(matches_a.size(), matches_b.size());
|
| - // The order should now be 3, 1, 2, 4.
|
| - EXPECT_EQ(3, matches_b[0].term_num);
|
| - EXPECT_EQ(1, matches_b[1].term_num);
|
| - EXPECT_EQ(2, matches_b[2].term_num);
|
| - EXPECT_EQ(4, matches_b[3].term_num);
|
| - matches_a.push_back(TermMatch(5, 18, 10));
|
| - matches_a.push_back(TermMatch(6, 38, 5));
|
| - matches_b = InMemoryURLIndex::SortAndDeoverlap(matches_a);
|
| - // Two matches should have been eliminated.
|
| - EXPECT_EQ(matches_a.size() - 2, matches_b.size());
|
| - // The order should now be 3, 1, 2, 6.
|
| - EXPECT_EQ(3, matches_b[0].term_num);
|
| - EXPECT_EQ(1, matches_b[1].term_num);
|
| - EXPECT_EQ(2, matches_b[2].term_num);
|
| - EXPECT_EQ(6, matches_b[3].term_num);
|
| -
|
| - // Test MatchTermInString
|
| - TermMatches matches_c = InMemoryURLIndex::MatchTermInString(
|
| - UTF8ToUTF16("x"), UTF8ToUTF16("axbxcxdxex fxgx/hxixjx.kx"), 123);
|
| - ASSERT_EQ(11U, matches_c.size());
|
| - const size_t expected_offsets[] = { 1, 3, 5, 7, 9, 12, 14, 17, 19, 21, 24 };
|
| - for (int i = 0; i < 11; ++i)
|
| - EXPECT_EQ(expected_offsets[i], matches_c[i].offset);
|
| -}
|
| -
|
| -TEST_F(InMemoryURLIndexTest, OffsetsAndTermMatches) {
|
| - // Test OffsetsFromTermMatches
|
| - history::TermMatches matches_a;
|
| - matches_a.push_back(history::TermMatch(1, 1, 2));
|
| - matches_a.push_back(history::TermMatch(2, 4, 3));
|
| - matches_a.push_back(history::TermMatch(3, 9, 1));
|
| - matches_a.push_back(history::TermMatch(3, 10, 1));
|
| - matches_a.push_back(history::TermMatch(4, 14, 5));
|
| - std::vector<size_t> offsets =
|
| - InMemoryURLIndex::OffsetsFromTermMatches(matches_a);
|
| - const size_t expected_offsets_a[] = {1, 4, 9, 10, 14};
|
| - ASSERT_EQ(offsets.size(), arraysize(expected_offsets_a));
|
| - for (size_t i = 0; i < offsets.size(); ++i)
|
| - EXPECT_EQ(expected_offsets_a[i], offsets[i]);
|
| -
|
| - // Test ReplaceOffsetsInTermMatches
|
| - offsets[2] = string16::npos;
|
| - history::TermMatches matches_b =
|
| - InMemoryURLIndex::ReplaceOffsetsInTermMatches(matches_a, offsets);
|
| - const size_t expected_offsets_b[] = {1, 4, 10, 14};
|
| - ASSERT_EQ(arraysize(expected_offsets_b), matches_b.size());
|
| - for (size_t i = 0; i < matches_b.size(); ++i)
|
| - EXPECT_EQ(expected_offsets_b[i], matches_b[i].offset);
|
| -}
|
| -
|
| TEST_F(InMemoryURLIndexTest, TypedCharacterCaching) {
|
| // Verify that match results for previously typed characters are retained
|
| // (in the term_char_word_set_cache_) and reused, if possible, in future
|
| @@ -447,7 +367,8 @@
|
| typedef InMemoryURLIndex::SearchTermCacheMap::iterator CacheIter;
|
| typedef InMemoryURLIndex::SearchTermCacheItem CacheItem;
|
|
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| url_index_->Init(this, "en,ja,hi,zh");
|
|
|
| InMemoryURLIndex::SearchTermCacheMap& cache(url_index_->search_term_cache_);
|
| @@ -460,7 +381,7 @@
|
|
|
| // Simulate typing "r" giving "r" in the simulated omnibox. The results for
|
| // 'r' will be not cached because it is only 1 character long.
|
| - InMemoryURLIndex::String16Vector terms;
|
| + String16Vector terms;
|
| string16 term_r = ASCIIToUTF16("r");
|
| terms.push_back(term_r);
|
| url_index_->HistoryItemsForTerms(terms);
|
| @@ -550,9 +471,10 @@
|
| }
|
|
|
| TEST_F(InMemoryURLIndexTest, AddNewRows) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| url_index_->Init(this, "en,ja,hi,zh");
|
| - InMemoryURLIndex::String16Vector terms;
|
| + String16Vector terms;
|
|
|
| // Verify that the row we're going to add does not already exist.
|
| URLID new_row_id = 87654321;
|
| @@ -564,20 +486,21 @@
|
| // Add a new row.
|
| URLRow new_row(GURL("http://www.brokeandaloneinmanitoba.com/"), new_row_id);
|
| new_row.set_last_visit(base::Time::Now());
|
| - url_index_->UpdateURL(new_row_id, new_row);
|
| + url_index_->UpdateURL(new_row);
|
|
|
| // Verify that we can retrieve it.
|
| EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(terms).size());
|
|
|
| // Add it again just to be sure that is harmless.
|
| - url_index_->UpdateURL(new_row_id, new_row);
|
| + url_index_->UpdateURL(new_row);
|
| EXPECT_EQ(1U, url_index_->HistoryItemsForTerms(terms).size());
|
| }
|
|
|
| TEST_F(InMemoryURLIndexTest, DeleteRows) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| url_index_->Init(this, "en,ja,hi,zh");
|
| - InMemoryURLIndex::String16Vector terms;
|
| + String16Vector terms;
|
|
|
| // Make sure we actually get an existing result.
|
| terms.push_back(ASCIIToUTF16("DrudgeReport"));
|
| @@ -585,7 +508,7 @@
|
| ASSERT_EQ(1U, matches.size());
|
|
|
| // Determine the row id for that result, delete that id, then search again.
|
| - url_index_->DeleteURL(matches[0].url_info.id());
|
| + url_index_->DeleteURL(matches[0].url_info);
|
| EXPECT_TRUE(url_index_->HistoryItemsForTerms(terms).empty());
|
| }
|
|
|
| @@ -662,7 +585,8 @@
|
| { "xmpp:node@example.com", false },
|
| { "xmpp://guest@example.com", false },
|
| };
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL(
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL(
|
| "/flammmy/frammy/"))));
|
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
|
| GURL url(data[i].url_spec);
|
| @@ -672,8 +596,8 @@
|
| }
|
|
|
| TEST_F(InMemoryURLIndexTest, CacheFilePath) {
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL(
|
| - "/flammmy/frammy/"))));
|
| + url_index_.reset(new InMemoryURLIndex(
|
| + NULL, FilePath(FILE_PATH_LITERAL("/flammmy/frammy/"))));
|
| FilePath full_file_path;
|
| url_index_->GetCacheFilePath(&full_file_path);
|
| std::vector<FilePath::StringType> expected_parts;
|
| @@ -689,84 +613,72 @@
|
|
|
| TEST_F(InMemoryURLIndexTest, CacheSaveRestore) {
|
| // Save the cache to a protobuf, restore it, and compare the results.
|
| - url_index_.reset(new InMemoryURLIndex(FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| + url_index_.reset(new InMemoryURLIndex(NULL,
|
| + FilePath(FILE_PATH_LITERAL("/dummy"))));
|
| InMemoryURLIndex& url_index(*(url_index_.get()));
|
| url_index.Init(this, "en,ja,hi,zh");
|
| in_memory_url_index::InMemoryURLIndexCacheItem index_cache;
|
| url_index.SavePrivateData(&index_cache);
|
|
|
| // Capture our private data so we can later compare for equality.
|
| - int history_item_count(url_index.history_item_count_);
|
| - InMemoryURLIndex::String16Vector word_list(url_index.word_list_);
|
| - InMemoryURLIndex::WordMap word_map(url_index.word_map_);
|
| - InMemoryURLIndex::CharWordIDMap char_word_map(url_index.char_word_map_);
|
| - InMemoryURLIndex::WordIDHistoryMap word_id_history_map(
|
| - url_index.word_id_history_map_);
|
| - InMemoryURLIndex::HistoryInfoMap history_info_map(
|
| - url_index.history_info_map_);
|
| + URLIndexPrivateData& private_data(*(url_index_->private_data_));
|
| + String16Vector word_list(private_data.word_list_);
|
| + WordMap word_map(private_data.word_map_);
|
| + CharWordIDMap char_word_map(private_data.char_word_map_);
|
| + WordIDHistoryMap word_id_history_map(private_data.word_id_history_map_);
|
| + HistoryIDWordMap history_id_word_map(private_data.history_id_word_map_);
|
| + HistoryInfoMap history_info_map(private_data.history_info_map_);
|
|
|
| // Prove that there is really something there.
|
| - EXPECT_GT(url_index.history_item_count_, 0);
|
| - EXPECT_FALSE(url_index.word_list_.empty());
|
| - EXPECT_FALSE(url_index.word_map_.empty());
|
| - EXPECT_FALSE(url_index.char_word_map_.empty());
|
| - EXPECT_FALSE(url_index.word_id_history_map_.empty());
|
| - EXPECT_FALSE(url_index.history_info_map_.empty());
|
| + EXPECT_FALSE(private_data.word_list_.empty());
|
| + // available_words_ will already be empty since we have freshly built the
|
| + // data set for this test.
|
| + EXPECT_TRUE(private_data.available_words_.empty());
|
| + EXPECT_FALSE(private_data.word_map_.empty());
|
| + EXPECT_FALSE(private_data.char_word_map_.empty());
|
| + EXPECT_FALSE(private_data.word_id_history_map_.empty());
|
| + EXPECT_FALSE(private_data.history_id_word_map_.empty());
|
| + EXPECT_FALSE(private_data.history_info_map_.empty());
|
|
|
| // Clear and then prove it's clear.
|
| url_index.ClearPrivateData();
|
| - EXPECT_EQ(0, url_index.history_item_count_);
|
| - EXPECT_TRUE(url_index.word_list_.empty());
|
| - EXPECT_TRUE(url_index.word_map_.empty());
|
| - EXPECT_TRUE(url_index.char_word_map_.empty());
|
| - EXPECT_TRUE(url_index.word_id_history_map_.empty());
|
| - EXPECT_TRUE(url_index.history_info_map_.empty());
|
| + EXPECT_TRUE(private_data.word_list_.empty());
|
| + EXPECT_TRUE(private_data.available_words_.empty());
|
| + EXPECT_TRUE(private_data.word_map_.empty());
|
| + EXPECT_TRUE(private_data.char_word_map_.empty());
|
| + EXPECT_TRUE(private_data.word_id_history_map_.empty());
|
| + EXPECT_TRUE(private_data.history_id_word_map_.empty());
|
| + EXPECT_TRUE(private_data.history_info_map_.empty());
|
|
|
| // Restore the cache.
|
| EXPECT_TRUE(url_index.RestorePrivateData(index_cache));
|
|
|
| // Compare the restored and captured for equality.
|
| - EXPECT_EQ(history_item_count, url_index.history_item_count_);
|
| - EXPECT_EQ(word_list.size(), url_index.word_list_.size());
|
| - EXPECT_EQ(word_map.size(), url_index.word_map_.size());
|
| - EXPECT_EQ(char_word_map.size(), url_index.char_word_map_.size());
|
| - EXPECT_EQ(word_id_history_map.size(), url_index.word_id_history_map_.size());
|
| - EXPECT_EQ(history_info_map.size(), url_index.history_info_map_.size());
|
| + EXPECT_EQ(word_list.size(), private_data.word_list_.size());
|
| + EXPECT_EQ(word_map.size(), private_data.word_map_.size());
|
| + EXPECT_EQ(char_word_map.size(), private_data.char_word_map_.size());
|
| + EXPECT_EQ(word_id_history_map.size(),
|
| + private_data.word_id_history_map_.size());
|
| + EXPECT_EQ(history_id_word_map.size(),
|
| + private_data.history_id_word_map_.size());
|
| + EXPECT_EQ(history_info_map.size(), private_data.history_info_map_.size());
|
| // WordList must be index-by-index equal.
|
| size_t count = word_list.size();
|
| for (size_t i = 0; i < count; ++i)
|
| - EXPECT_EQ(word_list[i], url_index.word_list_[i]);
|
| - for (InMemoryURLIndex::CharWordIDMap::const_iterator expected =
|
| - char_word_map.begin(); expected != char_word_map.end(); ++expected) {
|
| - InMemoryURLIndex::CharWordIDMap::const_iterator actual =
|
| - url_index.char_word_map_.find(expected->first);
|
| - ASSERT_TRUE(url_index.char_word_map_.end() != actual);
|
| - const InMemoryURLIndex::WordIDSet& expected_set(expected->second);
|
| - const InMemoryURLIndex::WordIDSet& actual_set(actual->second);
|
| - ASSERT_EQ(expected_set.size(), actual_set.size());
|
| - for (InMemoryURLIndex::WordIDSet::const_iterator set_iter =
|
| - expected_set.begin(); set_iter != expected_set.end(); ++set_iter)
|
| - EXPECT_GT(actual_set.count(*set_iter), 0U);
|
| - }
|
| - for (InMemoryURLIndex::WordIDHistoryMap::const_iterator expected =
|
| - word_id_history_map.begin(); expected != word_id_history_map.end();
|
| - ++expected) {
|
| - InMemoryURLIndex::WordIDHistoryMap::const_iterator actual =
|
| - url_index.word_id_history_map_.find(expected->first);
|
| - ASSERT_TRUE(url_index.word_id_history_map_.end() != actual);
|
| - const InMemoryURLIndex::HistoryIDSet& expected_set(expected->second);
|
| - const InMemoryURLIndex::HistoryIDSet& actual_set(actual->second);
|
| - ASSERT_EQ(expected_set.size(), actual_set.size());
|
| - for (InMemoryURLIndex::HistoryIDSet::const_iterator set_iter =
|
| - expected_set.begin(); set_iter != expected_set.end(); ++set_iter)
|
| - EXPECT_GT(actual_set.count(*set_iter), 0U);
|
| - }
|
| - for (InMemoryURLIndex::HistoryInfoMap::const_iterator expected =
|
| - history_info_map.begin(); expected != history_info_map.end();
|
| - ++expected) {
|
| - InMemoryURLIndex::HistoryInfoMap::const_iterator actual =
|
| - url_index.history_info_map_.find(expected->first);
|
| - ASSERT_FALSE(url_index.history_info_map_.end() == actual);
|
| + EXPECT_EQ(word_list[i], private_data.word_list_[i]);
|
| +
|
| + ExpectMapOfContainersIdentical(char_word_map,
|
| + private_data.char_word_map_);
|
| + ExpectMapOfContainersIdentical(word_id_history_map,
|
| + private_data.word_id_history_map_);
|
| + ExpectMapOfContainersIdentical(history_id_word_map,
|
| + private_data.history_id_word_map_);
|
| +
|
| + for (HistoryInfoMap::const_iterator expected = history_info_map.begin();
|
| + expected != history_info_map.end(); ++expected) {
|
| + HistoryInfoMap::const_iterator actual =
|
| + private_data.history_info_map_.find(expected->first);
|
| + ASSERT_FALSE(private_data.history_info_map_.end() == actual);
|
| const URLRow& expected_row(expected->second);
|
| const URLRow& actual_row(actual->second);
|
| EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count());
|
|
|