Parent path added to ArticleInfo
This commit is contained in:
parent
bd28984f7e
commit
e4520f4d21
3 changed files with 14 additions and 8 deletions
|
@ -6,17 +6,19 @@
|
|||
struct ArticleInfo
|
||||
{
|
||||
ArticleInfo() {}
|
||||
ArticleInfo(string const & url, string const & title, string const & thumbnailUrl)
|
||||
: m_url(url), m_title(title), m_thumbnailUrl(thumbnailUrl) {}
|
||||
ArticleInfo(string const & url, string const & title, string const & thumbnailUrl, string const & parentPath)
|
||||
: m_url(url), m_title(title), m_thumbnailUrl(thumbnailUrl), m_parentPath(parentPath) {}
|
||||
|
||||
string m_url;
|
||||
string m_title;
|
||||
string m_thumbnailUrl;
|
||||
string m_parentPath;
|
||||
};
|
||||
|
||||
inline bool operator == (ArticleInfo const & a1, ArticleInfo const & a2)
|
||||
{
|
||||
return a1.m_url == a2.m_url && a1.m_title == a2.m_title && a1.m_thumbnailUrl == a2.m_thumbnailUrl;
|
||||
return a1.m_url == a2.m_url && a1.m_title == a2.m_title &&
|
||||
a1.m_thumbnailUrl == a2.m_thumbnailUrl && a1.m_parentPath == a2.m_parentPath;
|
||||
}
|
||||
|
||||
// It's important that PrintTo() is defined in the SAME
|
||||
|
@ -24,5 +26,6 @@ inline bool operator == (ArticleInfo const & a1, ArticleInfo const & a2)
|
|||
inline void PrintTo(ArticleInfo const & artInfo, ::std::ostream* os) {
|
||||
*os << "ArticleInfi {" << artInfo.m_url << ", "
|
||||
<< artInfo.m_title << ", "
|
||||
<< artInfo.m_thumbnailUrl << "}";
|
||||
<< artInfo.m_thumbnailUrl << ", "
|
||||
<< artInfo.m_parentPath << "}";
|
||||
}
|
||||
|
|
|
@ -11,16 +11,19 @@ bool ArticleInfoStorageMock::GetArticleInfoById(ArticleInfo & out, ArticleInfoId
|
|||
out.m_thumbnailUrl = "london.jpg";
|
||||
out.m_url = "London";
|
||||
out.m_title = "London";
|
||||
out.m_parentPath = "Europe -> Great Britain";
|
||||
return true;
|
||||
case 1:
|
||||
out.m_thumbnailUrl = "lancaster.jpg";
|
||||
out.m_url = "Lancaster";
|
||||
out.m_title = "Lancaster";
|
||||
out.m_parentPath = "Europe -> Great Britain";
|
||||
return true;
|
||||
case 2:
|
||||
out.m_thumbnailUrl = "great_britain.jpg";
|
||||
out.m_url = "Great_Britain";
|
||||
out.m_title = "Great Britain";
|
||||
out.m_parentPath = "Europe";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -13,9 +13,9 @@ TEST(Storage, Smoke)
|
|||
|
||||
ArticleInfo expected[] =
|
||||
{
|
||||
ArticleInfo("London", "London", "london.jpg"),
|
||||
ArticleInfo("Lancaster", "Lancaster", "lancaster.jpg"),
|
||||
ArticleInfo("Great_Britain", "Great Britain", "great_britain.jpg"),
|
||||
ArticleInfo("London", "London", "london.jpg", "Europe -> Great Britain"),
|
||||
ArticleInfo("Lancaster", "Lancaster", "lancaster.jpg", "Europe -> Great Britain"),
|
||||
ArticleInfo("Great_Britain", "Great Britain", "great_britain.jpg", "Europe"),
|
||||
};
|
||||
|
||||
EXPECT_EQ(vector<ArticleInfo>(&expected[0], &expected[0] + 3), artInfos);
|
||||
|
@ -29,5 +29,5 @@ TEST(Storage, PrefixQuery)
|
|||
storage.QueryArticleInfos(artInfos, "Lo");
|
||||
|
||||
EXPECT_EQ(artInfos.size(), 1);
|
||||
EXPECT_EQ(artInfos[0], ArticleInfo("London", "London", "london.jpg"));
|
||||
EXPECT_EQ(artInfos[0], ArticleInfo("London", "London", "london.jpg", "Europe -> Great Britain"));
|
||||
}
|
||||
|
|
Reference in a new issue