OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Program to test the SafeBrowsing protocol parsing v2.1. | 5 // Program to test the SafeBrowsing protocol parsing v2.1. |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/safe_browsing/protocol_parser.h" | 8 #include "chrome/browser/safe_browsing/protocol_parser.h" |
9 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 // Test parsing one add chunk. | 12 // Test parsing one add chunk. |
13 TEST(SafeBrowsingProtocolParsingTest, TestAddChunk) { | 13 TEST(SafeBrowsingProtocolParsingTest, TestAddChunk) { |
14 std::string add_chunk("a:1:4:35\naaaax1111\0032222333344447777\00288889999"); | 14 std::string add_chunk("a:1:4:35\naaaax1111\0032222333344447777\00288889999"); |
15 add_chunk[13] = '\0'; | 15 add_chunk[13] = '\0'; |
16 | 16 |
17 // Run the parse. | 17 // Run the parse. |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 EXPECT_EQ(chunks[0].hosts[0].host, 0); | 775 EXPECT_EQ(chunks[0].hosts[0].host, 0); |
776 SBEntry* entry = chunks[0].hosts[0].entry; | 776 SBEntry* entry = chunks[0].hosts[0].entry; |
777 EXPECT_TRUE(entry->IsSub()); | 777 EXPECT_TRUE(entry->IsSub()); |
778 ASSERT_FALSE(entry->IsPrefix()); | 778 ASSERT_FALSE(entry->IsPrefix()); |
779 ASSERT_EQ(entry->prefix_count(), 1); | 779 ASSERT_EQ(entry->prefix_count(), 1); |
780 EXPECT_EQ(entry->ChunkIdAtPrefix(0), 0x31313131); | 780 EXPECT_EQ(entry->ChunkIdAtPrefix(0), 0x31313131); |
781 SBFullHash full; | 781 SBFullHash full; |
782 memcpy(full.full_hash, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 32); | 782 memcpy(full.full_hash, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 32); |
783 EXPECT_TRUE(entry->FullHashAt(0) == full); | 783 EXPECT_TRUE(entry->FullHashAt(0) == full); |
784 } | 784 } |
OLD | NEW |