Fixing search and tests added
This commit is contained in:
parent
9ec0e4b935
commit
adae6f7274
2 changed files with 34 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
|||
#include "../std/algorithm.hpp"
|
||||
#include "../std/utility.hpp"
|
||||
|
||||
#include "../env/strings.hpp"
|
||||
|
||||
|
||||
void Storage::QueryArticleInfos(vector<ArticleInfo> & out, string const & prefix,
|
||||
double lat, double lon) const
|
||||
|
@ -11,7 +13,7 @@ void Storage::QueryArticleInfos(vector<ArticleInfo> & out, string const & prefix
|
|||
|
||||
typedef vector<ArticleInfo>::const_iterator IterT;
|
||||
pair<IterT, IterT> const range = equal_range(m_info.begin(), m_info.end(),
|
||||
prefix, ArticleInfo::LessPrefix());
|
||||
str::MakeNormalizeAndLowerUtf8(prefix), ArticleInfo::LessPrefix());
|
||||
|
||||
out.assign(range.first, range.second);
|
||||
sort(out.begin(), out.end(), ArticleInfo::LessScore(lat, lon));
|
||||
|
|
|
@ -106,3 +106,34 @@ TEST(Storage, PrefixQuery_Utf8)
|
|||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Schließen", "Schließen");
|
||||
}
|
||||
|
||||
TEST(Storage, PrefixQuery_lowerCaseTest)
|
||||
{
|
||||
StorageTest storage;
|
||||
|
||||
char const * arrTitle[] = { "Great Britan"};
|
||||
size_t const count = ArraySize(arrTitle);
|
||||
|
||||
storage.FillStorage(arrTitle, count);
|
||||
|
||||
vector<ArticleInfo> out;
|
||||
storage.QueryArticleInfos(out, "");
|
||||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Great Britan", "Great Britan");
|
||||
|
||||
storage.QueryArticleInfos(out, "g");
|
||||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Great Britan", "Great Britan");
|
||||
|
||||
storage.QueryArticleInfos(out, "G");
|
||||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Great Britan", "Great Britan");
|
||||
|
||||
storage.QueryArticleInfos(out, "gR");
|
||||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Great Britan", "Great Britan");
|
||||
|
||||
storage.QueryArticleInfos(out, "GR");
|
||||
EXPECT_EQ(out.size(), 1);
|
||||
CheckBounds(out, "Great Britan", "Great Britan");
|
||||
}
|
||||
|
|
Reference in a new issue