| 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 '\x22', // field 4, wire format length-delimited | 32 '\x22', // field 4, wire format length-delimited |
| 33 '\x18', // varint length 24 | 33 '\x18', // varint length 24 |
| 34 '1', '1', '1', '1', // 4-byte prefixes | 34 '1', '1', '1', '1', // 4-byte prefixes |
| 35 '2', '2', '2', '2', | 35 '2', '2', '2', '2', |
| 36 '3', '3', '3', '3', | 36 '3', '3', '3', '3', |
| 37 '4', '4', '4', '4', | 37 '4', '4', '4', '4', |
| 38 '8', '8', '8', '8', | 38 '8', '8', '8', '8', |
| 39 '9', '9', '9', '9', | 39 '9', '9', '9', '9', |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 std::vector<scoped_ptr<SBChunkData>> chunks; | 42 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 43 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 43 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 44 ASSERT_EQ(1U, chunks.size()); | 44 ASSERT_EQ(1U, chunks.size()); |
| 45 EXPECT_EQ(1, chunks[0]->ChunkNumber()); | 45 EXPECT_EQ(1, chunks[0]->ChunkNumber()); |
| 46 EXPECT_TRUE(chunks[0]->IsAdd()); | 46 EXPECT_TRUE(chunks[0]->IsAdd()); |
| 47 EXPECT_FALSE(chunks[0]->IsSub()); | 47 EXPECT_FALSE(chunks[0]->IsSub()); |
| 48 EXPECT_TRUE(chunks[0]->IsPrefix()); | 48 EXPECT_TRUE(chunks[0]->IsPrefix()); |
| 49 EXPECT_FALSE(chunks[0]->IsFullHash()); | 49 EXPECT_FALSE(chunks[0]->IsFullHash()); |
| 50 ASSERT_EQ(6U, chunks[0]->PrefixCount()); | 50 ASSERT_EQ(6U, chunks[0]->PrefixCount()); |
| 51 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 | 51 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 |
| 52 EXPECT_EQ(0x32323232U, chunks[0]->PrefixAt(1)); // 2222 | 52 EXPECT_EQ(0x32323232U, chunks[0]->PrefixAt(1)); // 2222 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 77 '2', '3', '2', '3', '2', '3', '2', '3', | 77 '2', '3', '2', '3', '2', '3', '2', '3', |
| 78 '2', '3', '2', '3', '2', '3', '2', '3', | 78 '2', '3', '2', '3', '2', '3', '2', '3', |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 SBFullHash full_hash1, full_hash2; | 81 SBFullHash full_hash1, full_hash2; |
| 82 for (int i = 0; i < 32; ++i) { | 82 for (int i = 0; i < 32; ++i) { |
| 83 full_hash1.full_hash[i] = (i % 2) ? '1' : '0'; | 83 full_hash1.full_hash[i] = (i % 2) ? '1' : '0'; |
| 84 full_hash2.full_hash[i] = (i % 2) ? '3' : '2'; | 84 full_hash2.full_hash[i] = (i % 2) ? '3' : '2'; |
| 85 } | 85 } |
| 86 | 86 |
| 87 std::vector<scoped_ptr<SBChunkData>> chunks; | 87 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 88 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 88 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 89 ASSERT_EQ(1U, chunks.size()); | 89 ASSERT_EQ(1U, chunks.size()); |
| 90 EXPECT_EQ(1, chunks[0]->ChunkNumber()); | 90 EXPECT_EQ(1, chunks[0]->ChunkNumber()); |
| 91 EXPECT_TRUE(chunks[0]->IsAdd()); | 91 EXPECT_TRUE(chunks[0]->IsAdd()); |
| 92 EXPECT_FALSE(chunks[0]->IsSub()); | 92 EXPECT_FALSE(chunks[0]->IsSub()); |
| 93 EXPECT_FALSE(chunks[0]->IsPrefix()); | 93 EXPECT_FALSE(chunks[0]->IsPrefix()); |
| 94 EXPECT_TRUE(chunks[0]->IsFullHash()); | 94 EXPECT_TRUE(chunks[0]->IsFullHash()); |
| 95 | 95 |
| 96 ASSERT_EQ(2U, chunks[0]->FullHashCount()); | 96 ASSERT_EQ(2U, chunks[0]->FullHashCount()); |
| 97 EXPECT_TRUE(SBFullHashEqual(chunks[0]->FullHashAt(0), full_hash1)); | 97 EXPECT_TRUE(SBFullHashEqual(chunks[0]->FullHashAt(0), full_hash1)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 | 117 |
| 118 '\0', '\0', '\0', '\x0C', // 32-bit payload length in network byte order. | 118 '\0', '\0', '\0', '\x0C', // 32-bit payload length in network byte order. |
| 119 '\x08', // field 1, wire format varint | 119 '\x08', // field 1, wire format varint |
| 120 '\x02', // chunk_number varint 1 | 120 '\x02', // chunk_number varint 1 |
| 121 '\x22', // field 4, wire format length-delimited | 121 '\x22', // field 4, wire format length-delimited |
| 122 '\x08', // varint length 8 | 122 '\x08', // varint length 8 |
| 123 'p', 'p', 'p', 'p', // 4-byte prefixes | 123 'p', 'p', 'p', 'p', // 4-byte prefixes |
| 124 'g', 'g', 'g', 'g', | 124 'g', 'g', 'g', 'g', |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 std::vector<scoped_ptr<SBChunkData>> chunks; | 127 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 128 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 128 EXPECT_TRUE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 129 ASSERT_EQ(2U, chunks.size()); | 129 ASSERT_EQ(2U, chunks.size()); |
| 130 | 130 |
| 131 EXPECT_EQ(1, chunks[0]->ChunkNumber()); | 131 EXPECT_EQ(1, chunks[0]->ChunkNumber()); |
| 132 EXPECT_TRUE(chunks[0]->IsAdd()); | 132 EXPECT_TRUE(chunks[0]->IsAdd()); |
| 133 EXPECT_FALSE(chunks[0]->IsSub()); | 133 EXPECT_FALSE(chunks[0]->IsSub()); |
| 134 EXPECT_TRUE(chunks[0]->IsPrefix()); | 134 EXPECT_TRUE(chunks[0]->IsPrefix()); |
| 135 EXPECT_FALSE(chunks[0]->IsFullHash()); | 135 EXPECT_FALSE(chunks[0]->IsFullHash()); |
| 136 ASSERT_EQ(6U, chunks[0]->PrefixCount()); | 136 ASSERT_EQ(6U, chunks[0]->PrefixCount()); |
| 137 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 | 137 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 157 '\0', '\0', '\0', '\x1C', // 32-bit payload length in network byte order. | 157 '\0', '\0', '\0', '\x1C', // 32-bit payload length in network byte order. |
| 158 '\x08', // field 1, wire format varint | 158 '\x08', // field 1, wire format varint |
| 159 '\x01', // chunk_number varint 1 | 159 '\x01', // chunk_number varint 1 |
| 160 '\x22', // field 4, wire format length-delimited | 160 '\x22', // field 4, wire format length-delimited |
| 161 '\x18', // varint length 24 | 161 '\x18', // varint length 24 |
| 162 '1', '1', '1', '1', // 4-byte prefixes | 162 '1', '1', '1', '1', // 4-byte prefixes |
| 163 '2', '2', '2', '2', | 163 '2', '2', '2', '2', |
| 164 '3', '3', '3', '3', | 164 '3', '3', '3', '3', |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 std::vector<scoped_ptr<SBChunkData>> chunks; | 167 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 168 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 168 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 TEST(SafeBrowsingProtocolParsingTest, TestTruncatedFullHashChunk) { | 171 TEST(SafeBrowsingProtocolParsingTest, TestTruncatedFullHashChunk) { |
| 172 // This chunk delares there are two full hashes but there is only one. | 172 // This chunk delares there are two full hashes but there is only one. |
| 173 const char kRawAddChunk[] = { | 173 const char kRawAddChunk[] = { |
| 174 '\0', '\0', '\0', '\x46', // 32-bit payload length in network byte order. | 174 '\0', '\0', '\0', '\x46', // 32-bit payload length in network byte order. |
| 175 '\x08', // field 1, wire format varint | 175 '\x08', // field 1, wire format varint |
| 176 '\x01', // chunk_number varint 1 | 176 '\x01', // chunk_number varint 1 |
| 177 '\x18', // field 3, wire format varint | 177 '\x18', // field 3, wire format varint |
| 178 '\x01', // enum PrefixType == FULL_32B | 178 '\x01', // enum PrefixType == FULL_32B |
| 179 '\x22', // field 4, wire format length-delimited | 179 '\x22', // field 4, wire format length-delimited |
| 180 '\x40', // varint length 64 (2 full hashes) | 180 '\x40', // varint length 64 (2 full hashes) |
| 181 | 181 |
| 182 '0', '1', '0', '1', '0', '1', '0', '1', | 182 '0', '1', '0', '1', '0', '1', '0', '1', |
| 183 '0', '1', '0', '1', '0', '1', '0', '1', | 183 '0', '1', '0', '1', '0', '1', '0', '1', |
| 184 '0', '1', '0', '1', '0', '1', '0', '1', | 184 '0', '1', '0', '1', '0', '1', '0', '1', |
| 185 '0', '1', '0', '1', '0', '1', '0', '1', | 185 '0', '1', '0', '1', '0', '1', '0', '1', |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 std::vector<scoped_ptr<SBChunkData>> chunks; | 188 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 189 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 189 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TEST(SafeBrowsingProtocolParsingTest, TestHugeChunk) { | 192 TEST(SafeBrowsingProtocolParsingTest, TestHugeChunk) { |
| 193 // This chunk delares there are 6 prefixes but actually only contains 3. | 193 // This chunk delares there are 6 prefixes but actually only contains 3. |
| 194 const char kRawAddChunk[] = { | 194 const char kRawAddChunk[] = { |
| 195 '\x1', '\0', '\0', '\0', // 32-bit payload length in network byte order. | 195 '\x1', '\0', '\0', '\0', // 32-bit payload length in network byte order. |
| 196 '\x08', // field 1, wire format varint | 196 '\x08', // field 1, wire format varint |
| 197 '\x01', // chunk_number varint 1 | 197 '\x01', // chunk_number varint 1 |
| 198 '\x22', // field 4, wire format length-delimited | 198 '\x22', // field 4, wire format length-delimited |
| 199 '\x18', // varint length 24 | 199 '\x18', // varint length 24 |
| 200 '1', '1', '1', '1', // 4-byte prefixes | 200 '1', '1', '1', '1', // 4-byte prefixes |
| 201 '2', '2', '2', '2', | 201 '2', '2', '2', '2', |
| 202 '3', '3', '3', '3', | 202 '3', '3', '3', '3', |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 std::vector<scoped_ptr<SBChunkData>> chunks; | 205 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 206 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); | 206 EXPECT_FALSE(ParseChunk(kRawAddChunk, sizeof(kRawAddChunk), &chunks)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Test parsing one sub chunk. | 209 // Test parsing one sub chunk. |
| 210 TEST(SafeBrowsingProtocolParsingTest, TestSubChunk) { | 210 TEST(SafeBrowsingProtocolParsingTest, TestSubChunk) { |
| 211 const char kRawSubChunk[] = { | 211 const char kRawSubChunk[] = { |
| 212 '\0', '\0', '\0', '\x12', // 32-bit payload length in network byte order | 212 '\0', '\0', '\0', '\x12', // 32-bit payload length in network byte order |
| 213 '\x08', // field 1, wire format varint | 213 '\x08', // field 1, wire format varint |
| 214 '\x03', // chunk_number varint 3 | 214 '\x03', // chunk_number varint 3 |
| 215 '\x10', // field 2, wire format varint | 215 '\x10', // field 2, wire format varint |
| 216 '\x01', // enum ChunkType == SUB | 216 '\x01', // enum ChunkType == SUB |
| 217 '\x22', // field 4, wire format length-delimited | 217 '\x22', // field 4, wire format length-delimited |
| 218 '\x08', // varint length 8 (2 prefixes) | 218 '\x08', // varint length 8 (2 prefixes) |
| 219 '1', '1', '1', '1', // 4-byte prefixes | 219 '1', '1', '1', '1', // 4-byte prefixes |
| 220 '2', '2', '2', '2', | 220 '2', '2', '2', '2', |
| 221 '\x2a', // field 5, wire format length-delimited | 221 '\x2a', // field 5, wire format length-delimited |
| 222 '\x02', // varint length 2 (2 add-chunk numbers) | 222 '\x02', // varint length 2 (2 add-chunk numbers) |
| 223 '\x07', '\x09', // varint 7, varint 9 | 223 '\x07', '\x09', // varint 7, varint 9 |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 std::vector<scoped_ptr<SBChunkData>> chunks; | 226 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 227 EXPECT_TRUE(ParseChunk(kRawSubChunk, sizeof(kRawSubChunk), &chunks)); | 227 EXPECT_TRUE(ParseChunk(kRawSubChunk, sizeof(kRawSubChunk), &chunks)); |
| 228 ASSERT_EQ(1U, chunks.size()); | 228 ASSERT_EQ(1U, chunks.size()); |
| 229 EXPECT_EQ(3, chunks[0]->ChunkNumber()); | 229 EXPECT_EQ(3, chunks[0]->ChunkNumber()); |
| 230 EXPECT_FALSE(chunks[0]->IsAdd()); | 230 EXPECT_FALSE(chunks[0]->IsAdd()); |
| 231 EXPECT_TRUE(chunks[0]->IsSub()); | 231 EXPECT_TRUE(chunks[0]->IsSub()); |
| 232 EXPECT_TRUE(chunks[0]->IsPrefix()); | 232 EXPECT_TRUE(chunks[0]->IsPrefix()); |
| 233 EXPECT_FALSE(chunks[0]->IsFullHash()); | 233 EXPECT_FALSE(chunks[0]->IsFullHash()); |
| 234 ASSERT_EQ(2U, chunks[0]->PrefixCount()); | 234 ASSERT_EQ(2U, chunks[0]->PrefixCount()); |
| 235 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 | 235 EXPECT_EQ(0x31313131U, chunks[0]->PrefixAt(0)); // 1111 |
| 236 EXPECT_EQ(7, chunks[0]->AddChunkNumberAt(0)); | 236 EXPECT_EQ(7, chunks[0]->AddChunkNumberAt(0)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 265 '\x02', // varint length 2 (2 add-chunk numbers) | 265 '\x02', // varint length 2 (2 add-chunk numbers) |
| 266 '\x07', '\x09', // varint 7, varint 9 | 266 '\x07', '\x09', // varint 7, varint 9 |
| 267 }; | 267 }; |
| 268 | 268 |
| 269 SBFullHash full_hash1, full_hash2; | 269 SBFullHash full_hash1, full_hash2; |
| 270 for (int i = 0; i < 32; ++i) { | 270 for (int i = 0; i < 32; ++i) { |
| 271 full_hash1.full_hash[i] = i % 2 ? '1' : '0'; | 271 full_hash1.full_hash[i] = i % 2 ? '1' : '0'; |
| 272 full_hash2.full_hash[i] = i % 2 ? '3' : '2'; | 272 full_hash2.full_hash[i] = i % 2 ? '3' : '2'; |
| 273 } | 273 } |
| 274 | 274 |
| 275 std::vector<scoped_ptr<SBChunkData>> chunks; | 275 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 276 EXPECT_TRUE(ParseChunk(kRawSubChunk, sizeof(kRawSubChunk), &chunks)); | 276 EXPECT_TRUE(ParseChunk(kRawSubChunk, sizeof(kRawSubChunk), &chunks)); |
| 277 ASSERT_EQ(1U, chunks.size()); | 277 ASSERT_EQ(1U, chunks.size()); |
| 278 EXPECT_EQ(2, chunks[0]->ChunkNumber()); | 278 EXPECT_EQ(2, chunks[0]->ChunkNumber()); |
| 279 EXPECT_FALSE(chunks[0]->IsAdd()); | 279 EXPECT_FALSE(chunks[0]->IsAdd()); |
| 280 EXPECT_TRUE(chunks[0]->IsSub()); | 280 EXPECT_TRUE(chunks[0]->IsSub()); |
| 281 EXPECT_FALSE(chunks[0]->IsPrefix()); | 281 EXPECT_FALSE(chunks[0]->IsPrefix()); |
| 282 EXPECT_TRUE(chunks[0]->IsFullHash()); | 282 EXPECT_TRUE(chunks[0]->IsFullHash()); |
| 283 | 283 |
| 284 ASSERT_EQ(2U, chunks[0]->FullHashCount()); | 284 ASSERT_EQ(2U, chunks[0]->FullHashCount()); |
| 285 EXPECT_TRUE(SBFullHashEqual(chunks[0]->FullHashAt(0), full_hash1)); | 285 EXPECT_TRUE(SBFullHashEqual(chunks[0]->FullHashAt(0), full_hash1)); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // The SafeBrowsing service will occasionally send zero length chunks so that | 569 // The SafeBrowsing service will occasionally send zero length chunks so that |
| 570 // client requests will have longer contiguous chunk number ranges, and thus | 570 // client requests will have longer contiguous chunk number ranges, and thus |
| 571 // reduce the request size. | 571 // reduce the request size. |
| 572 TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeAddChunk) { | 572 TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeAddChunk) { |
| 573 const char kEmptyAddChunk[] = { | 573 const char kEmptyAddChunk[] = { |
| 574 '\0', '\0', '\0', '\x02', // 32-bit payload length in network byte order. | 574 '\0', '\0', '\0', '\x02', // 32-bit payload length in network byte order. |
| 575 '\x08', // field 1, wire format varint | 575 '\x08', // field 1, wire format varint |
| 576 '\x02', // chunk_number varint 2 | 576 '\x02', // chunk_number varint 2 |
| 577 }; | 577 }; |
| 578 | 578 |
| 579 std::vector<scoped_ptr<SBChunkData>> chunks; | 579 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 580 EXPECT_TRUE(ParseChunk(kEmptyAddChunk, sizeof(kEmptyAddChunk), &chunks)); | 580 EXPECT_TRUE(ParseChunk(kEmptyAddChunk, sizeof(kEmptyAddChunk), &chunks)); |
| 581 ASSERT_EQ(1U, chunks.size()); | 581 ASSERT_EQ(1U, chunks.size()); |
| 582 EXPECT_EQ(2, chunks[0]->ChunkNumber()); | 582 EXPECT_EQ(2, chunks[0]->ChunkNumber()); |
| 583 EXPECT_TRUE(chunks[0]->IsAdd()); | 583 EXPECT_TRUE(chunks[0]->IsAdd()); |
| 584 EXPECT_FALSE(chunks[0]->IsSub()); | 584 EXPECT_FALSE(chunks[0]->IsSub()); |
| 585 EXPECT_TRUE(chunks[0]->IsPrefix()); | 585 EXPECT_TRUE(chunks[0]->IsPrefix()); |
| 586 EXPECT_FALSE(chunks[0]->IsFullHash()); | 586 EXPECT_FALSE(chunks[0]->IsFullHash()); |
| 587 EXPECT_EQ(0U, chunks[0]->PrefixCount()); | 587 EXPECT_EQ(0U, chunks[0]->PrefixCount()); |
| 588 | 588 |
| 589 // Now test a zero size chunk in between normal chunks. | 589 // Now test a zero size chunk in between normal chunks. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // Test parsing a zero sized sub chunk. | 640 // Test parsing a zero sized sub chunk. |
| 641 TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeSubChunk) { | 641 TEST(SafeBrowsingProtocolParsingTest, TestZeroSizeSubChunk) { |
| 642 const char kEmptySubChunk[] = { | 642 const char kEmptySubChunk[] = { |
| 643 '\0', '\0', '\0', '\x04', // 32-bit payload length in network byte order. | 643 '\0', '\0', '\0', '\x04', // 32-bit payload length in network byte order. |
| 644 '\x08', // field 1, wire format varint | 644 '\x08', // field 1, wire format varint |
| 645 '\x02', // chunk_number varint 2 | 645 '\x02', // chunk_number varint 2 |
| 646 '\x10', // field 2, wire format varint | 646 '\x10', // field 2, wire format varint |
| 647 '\x01', // enum ChunkType == SUB | 647 '\x01', // enum ChunkType == SUB |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 std::vector<scoped_ptr<SBChunkData>> chunks; | 650 std::vector<std::unique_ptr<SBChunkData>> chunks; |
| 651 EXPECT_TRUE(ParseChunk(kEmptySubChunk, sizeof(kEmptySubChunk), &chunks)); | 651 EXPECT_TRUE(ParseChunk(kEmptySubChunk, sizeof(kEmptySubChunk), &chunks)); |
| 652 ASSERT_EQ(1U, chunks.size()); | 652 ASSERT_EQ(1U, chunks.size()); |
| 653 EXPECT_EQ(2, chunks[0]->ChunkNumber()); | 653 EXPECT_EQ(2, chunks[0]->ChunkNumber()); |
| 654 EXPECT_FALSE(chunks[0]->IsAdd()); | 654 EXPECT_FALSE(chunks[0]->IsAdd()); |
| 655 EXPECT_TRUE(chunks[0]->IsSub()); | 655 EXPECT_TRUE(chunks[0]->IsSub()); |
| 656 EXPECT_TRUE(chunks[0]->IsPrefix()); | 656 EXPECT_TRUE(chunks[0]->IsPrefix()); |
| 657 EXPECT_FALSE(chunks[0]->IsFullHash()); | 657 EXPECT_FALSE(chunks[0]->IsFullHash()); |
| 658 EXPECT_EQ(0U, chunks[0]->PrefixCount()); | 658 EXPECT_EQ(0U, chunks[0]->PrefixCount()); |
| 659 | 659 |
| 660 // Test parsing a zero sized sub chunk mixed in with content carrying chunks. | 660 // Test parsing a zero sized sub chunk mixed in with content carrying chunks. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 EXPECT_FALSE(chunks[0]->IsAdd()); | 717 EXPECT_FALSE(chunks[0]->IsAdd()); |
| 718 EXPECT_TRUE(chunks[0]->IsSub()); | 718 EXPECT_TRUE(chunks[0]->IsSub()); |
| 719 EXPECT_TRUE(chunks[2]->IsPrefix()); | 719 EXPECT_TRUE(chunks[2]->IsPrefix()); |
| 720 EXPECT_FALSE(chunks[2]->IsFullHash()); | 720 EXPECT_FALSE(chunks[2]->IsFullHash()); |
| 721 ASSERT_EQ(1U, chunks[2]->PrefixCount()); | 721 ASSERT_EQ(1U, chunks[2]->PrefixCount()); |
| 722 EXPECT_EQ(0x70707070U, chunks[2]->PrefixAt(0)); // pppp | 722 EXPECT_EQ(0x70707070U, chunks[2]->PrefixAt(0)); // pppp |
| 723 EXPECT_EQ(11, chunks[2]->AddChunkNumberAt(0)); | 723 EXPECT_EQ(11, chunks[2]->AddChunkNumberAt(0)); |
| 724 } | 724 } |
| 725 | 725 |
| 726 } // namespace safe_browsing | 726 } // namespace safe_browsing |
| OLD | NEW |