OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "components/safe_browsing_db/util.h" | 8 #include "components/safe_browsing_db/util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 namespace { | 12 namespace safe_browsing { |
13 | 13 |
14 bool VectorContains(const std::vector<std::string>& data, | 14 bool VectorContains(const std::vector<std::string>& data, |
15 const std::string& str) { | 15 const std::string& str) { |
16 return std::find(data.begin(), data.end(), str) != data.end(); | 16 return std::find(data.begin(), data.end(), str) != data.end(); |
17 } | 17 } |
mattm
2015/11/11 01:10:17
Keep helpers inside anon namespace
vakh (old account. dont use)
2015/11/11 18:59:53
Done.
| |
18 | 18 |
19 // Tests that we generate the required host/path combinations for testing | 19 // Tests that we generate the required host/path combinations for testing |
20 // according to the Safe Browsing spec. | 20 // according to the Safe Browsing spec. |
21 // See section 6.2 in | 21 // See section 6.2 in |
22 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. | 22 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. |
23 TEST(SafeBrowsingDbUtilTest, UrlParsing) { | 23 TEST(SafeBrowsingDbUtilTest, UrlParsing) { |
24 std::vector<std::string> hosts, paths; | 24 std::vector<std::string> hosts, paths; |
25 | 25 |
26 GURL url("http://a.b.c/1/2.html?param=1"); | 26 GURL url("http://a.b.c/1/2.html?param=1"); |
27 safe_browsing::GenerateHostsToCheck(url, &hosts); | 27 safe_browsing::GenerateHostsToCheck(url, &hosts); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 EXPECT_FALSE(safe_browsing::SBFullHashEqual(kHash1, kHash2)); | 329 EXPECT_FALSE(safe_browsing::SBFullHashEqual(kHash1, kHash2)); |
330 EXPECT_FALSE(safe_browsing::SBFullHashEqual(kHash2, kHash1)); | 330 EXPECT_FALSE(safe_browsing::SBFullHashEqual(kHash2, kHash1)); |
331 | 331 |
332 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash1, kHash2)); | 332 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash1, kHash2)); |
333 EXPECT_TRUE(safe_browsing::SBFullHashLess(kHash2, kHash1)); | 333 EXPECT_TRUE(safe_browsing::SBFullHashLess(kHash2, kHash1)); |
334 | 334 |
335 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash1, kHash1)); | 335 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash1, kHash1)); |
336 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash2, kHash2)); | 336 EXPECT_FALSE(safe_browsing::SBFullHashLess(kHash2, kHash2)); |
337 } | 337 } |
338 | 338 |
339 } // namespace | 339 } // namespace safe_browsing |
OLD | NEW |