fix in index storage mock

This commit is contained in:
ExMix 2013-08-05 14:15:26 +03:00
parent 66b23404bf
commit 96eaa6f2f2
2 changed files with 13 additions and 2 deletions

View file

@ -10,6 +10,6 @@ void IndexStorageMock::QueryArticleInfos(vector<ArticleInfoId> & out, string co
else if (prefix == "L")
for (uint32_t i = 0; i < 2; ++i)
out.push_back(i);
else if (prefix.size() <= 6 && string("London").substr(prefix.size()) == prefix)
out.push_back(1);
else if (prefix.size() <= 6 && string("London").substr(0, prefix.size()) == prefix)
out.push_back(0);
}

View file

@ -20,3 +20,14 @@ TEST(Storage, Smoke)
EXPECT_EQ(vector<ArticleInfo>(&expected[0], &expected[0] + 3), artInfos);
}
TEST(Storage, PrefixQuery)
{
Storage storage(new ArticleInfoStorageMock(), new IndexStorageMock());
vector<ArticleInfo> artInfos;
storage.QueryArticleInfos(artInfos, "Lo");
EXPECT_EQ(artInfos.size(), 1);
EXPECT_EQ(artInfos[0], ArticleInfo("London", "London", "stub_url.png"));
}