Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_util_unittest.cc

Issue 1399843003: Move prefix_set and parts of s_b_util into a new component safe_browsing_db. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use group instead of a static_library for targets that have no sources. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/safe_browsing/safe_browsing_util.h" 8 #include "chrome/browser/safe_browsing/safe_browsing_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"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // 31 chars plus the last \0 as full_hash. 313 // 31 chars plus the last \0 as full_hash.
314 const std::string hash_in = "12345678902234567890323456789012"; 314 const std::string hash_in = "12345678902234567890323456789012";
315 SBFullHash hash_out = safe_browsing_util::StringToSBFullHash(hash_in); 315 SBFullHash hash_out = safe_browsing_util::StringToSBFullHash(hash_in);
316 EXPECT_EQ(0x34333231U, hash_out.prefix); 316 EXPECT_EQ(0x34333231U, hash_out.prefix);
317 EXPECT_EQ(0, memcmp(hash_in.data(), hash_out.full_hash, sizeof(SBFullHash))); 317 EXPECT_EQ(0, memcmp(hash_in.data(), hash_out.full_hash, sizeof(SBFullHash)));
318 318
319 std::string hash_final = safe_browsing_util::SBFullHashToString(hash_out); 319 std::string hash_final = safe_browsing_util::SBFullHashToString(hash_out);
320 EXPECT_EQ(hash_in, hash_final); 320 EXPECT_EQ(hash_in, hash_final);
321 } 321 }
322 322
323 TEST(SafeBrowsingUtilTest, FullHashOperators) {
324 const SBFullHash kHash1 = SBFullHashForString("one");
325 const SBFullHash kHash2 = SBFullHashForString("two");
326
327 EXPECT_TRUE(SBFullHashEqual(kHash1, kHash1));
328 EXPECT_TRUE(SBFullHashEqual(kHash2, kHash2));
329 EXPECT_FALSE(SBFullHashEqual(kHash1, kHash2));
330 EXPECT_FALSE(SBFullHashEqual(kHash2, kHash1));
331
332 EXPECT_FALSE(SBFullHashLess(kHash1, kHash2));
333 EXPECT_TRUE(SBFullHashLess(kHash2, kHash1));
334
335 EXPECT_FALSE(SBFullHashLess(kHash1, kHash1));
336 EXPECT_FALSE(SBFullHashLess(kHash2, kHash2));
337 }
338
339 } // namespace 323 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698