diff options
author | dhsharp <dhsharp@chromium.org> | 2015-11-17 16:15:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-18 00:16:36 +0000 |
commit | ffba2e3a9043416a7e2ec1500482b0f4182b76c7 (patch) | |
tree | ef04048382ff3f53ce429d1dc18bbba9617d2847 /extensions/common/url_pattern_set_unittest.cc | |
parent | 3b584ee5ef83c5c5ee9474961c8b47cb08a0f772 (diff) | |
download | chromium_src-ffba2e3a9043416a7e2ec1500482b0f4182b76c7.zip chromium_src-ffba2e3a9043416a7e2ec1500482b0f4182b76c7.tar.gz chromium_src-ffba2e3a9043416a7e2ec1500482b0f4182b76c7.tar.bz2 |
URLPatternSet::ToStringVector does not need to call std::unique().
std::unique() was being called incorrectly. std::unique() returns an
iterator pointing to the new end of the range, but the container itself
is not shortened. Correct usage requires that the vector contents after
the returned new end be erase()'d.
The code review for the change[0] introducing this call pointed out that the call
was also not needed. Remove the call, and add a rudimentary unit test for this
function.
[0] https://codereview.chromium.org/377553003
TEST=added unit test
Review URL: https://codereview.chromium.org/1449053005
Cr-Commit-Position: refs/heads/master@{#360222}
Diffstat (limited to 'extensions/common/url_pattern_set_unittest.cc')
-rw-r--r-- | extensions/common/url_pattern_set_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/common/url_pattern_set_unittest.cc b/extensions/common/url_pattern_set_unittest.cc index ce18203..3929a72 100644 --- a/extensions/common/url_pattern_set_unittest.cc +++ b/extensions/common/url_pattern_set_unittest.cc @@ -455,4 +455,23 @@ TEST(URLPatternSetTest, AddOrigin) { URLPattern::SCHEME_HTTP, GURL("https://google.com/"))); } +TEST(URLPatternSetTest, ToStringVector) { + URLPatternSet set; + AddPattern(&set, "https://google.com/"); + AddPattern(&set, "https://google.com/"); + AddPattern(&set, "https://yahoo.com/"); + + scoped_ptr<std::vector<std::string>> string_vector(set.ToStringVector()); + + EXPECT_EQ(2UL, string_vector->size()); + + const auto begin = string_vector->begin(); + const auto end = string_vector->end(); + + auto it = std::find(begin, end, "https://google.com/"); + EXPECT_NE(it, end); + it = std::find(begin, end, "https://yahoo.com/"); + EXPECT_NE(it, end); +} + } // namespace extensions |