| OLD | NEW |
| 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/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "crypto/sha2.h" | 8 #include "crypto/sha2.h" |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 TEST(SafeBrowsingUtilTest, ListIdVerification) { | 331 TEST(SafeBrowsingUtilTest, ListIdVerification) { |
| 332 EXPECT_EQ(0, safe_browsing_util::MALWARE % 2); | 332 EXPECT_EQ(0, safe_browsing_util::MALWARE % 2); |
| 333 EXPECT_EQ(1, safe_browsing_util::PHISH % 2); | 333 EXPECT_EQ(1, safe_browsing_util::PHISH % 2); |
| 334 EXPECT_EQ(0, safe_browsing_util::BINURL %2); | 334 EXPECT_EQ(0, safe_browsing_util::BINURL %2); |
| 335 EXPECT_EQ(1, safe_browsing_util::BINHASH % 2); | 335 EXPECT_EQ(1, safe_browsing_util::BINHASH % 2); |
| 336 } | 336 } |
| 337 | 337 |
| 338 TEST(SafeBrowsingUtilTest, StringToSBFullHashAndSBFullHashToString) { | 338 TEST(SafeBrowsingUtilTest, StringToSBFullHashAndSBFullHashToString) { |
| 339 // 31 chars plus the last \0 as full_hash. | 339 // 31 chars plus the last \0 as full_hash. |
| 340 const std::string hash_in = "12345678902234567890323456789012"; | 340 const std::string hash_in = "12345678902234567890323456789012"; |
| 341 SBFullHash hash_out; | 341 SBFullHash hash_out = safe_browsing_util::StringToSBFullHash(hash_in); |
| 342 safe_browsing_util::StringToSBFullHash(hash_in, &hash_out); | |
| 343 EXPECT_EQ(0x34333231, hash_out.prefix); | 342 EXPECT_EQ(0x34333231, hash_out.prefix); |
| 344 EXPECT_EQ(0, memcmp(hash_in.data(), hash_out.full_hash, sizeof(SBFullHash))); | 343 EXPECT_EQ(0, memcmp(hash_in.data(), hash_out.full_hash, sizeof(SBFullHash))); |
| 345 | 344 |
| 346 std::string hash_final = safe_browsing_util::SBFullHashToString(hash_out); | 345 std::string hash_final = safe_browsing_util::SBFullHashToString(hash_out); |
| 347 EXPECT_EQ(hash_in, hash_final); | 346 EXPECT_EQ(hash_in, hash_final); |
| 348 } | 347 } |
| OLD | NEW |