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 "net/base/ip_address.h" | 5 #include "net/base/ip_address.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 "192.168.1.1/-1", | 497 "192.168.1.1/-1", |
498 "192.168.1.1/33", | 498 "192.168.1.1/33", |
499 "::1/-3", | 499 "::1/-3", |
500 "a::3/129", | 500 "a::3/129", |
501 "::1/x", | 501 "::1/x", |
502 "192.168.0.1//11", | 502 "192.168.0.1//11", |
503 "192.168.1.1/+1", | 503 "192.168.1.1/+1", |
504 "192.168.1.1/ +1", | 504 "192.168.1.1/ +1", |
505 "192.168.1.1/"}; | 505 "192.168.1.1/"}; |
506 | 506 |
507 for (const auto& bad_literal : bad_literals) { | 507 for (auto* bad_literal : bad_literals) { |
508 IPAddress ip_address; | 508 IPAddress ip_address; |
509 size_t prefix_length_in_bits; | 509 size_t prefix_length_in_bits; |
510 | 510 |
511 EXPECT_FALSE( | 511 EXPECT_FALSE( |
512 ParseCIDRBlock(bad_literal, &ip_address, &prefix_length_in_bits)); | 512 ParseCIDRBlock(bad_literal, &ip_address, &prefix_length_in_bits)); |
513 } | 513 } |
514 } | 514 } |
515 | 515 |
516 // Test parsing a valid CIDR notation literal. | 516 // Test parsing a valid CIDR notation literal. |
517 TEST(IPAddressTest, ParseCIDRBlock_Valid) { | 517 TEST(IPAddressTest, ParseCIDRBlock_Valid) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 | 593 |
594 // Prefix is longer than the address. | 594 // Prefix is longer than the address. |
595 uint8_t ipv6_prefix5[] = {42, 0, 20, 80, 64, 12, 12, 9, 0, | 595 uint8_t ipv6_prefix5[] = {42, 0, 20, 80, 64, 12, 12, 9, 0, |
596 0, 0, 0, 0, 0, 0, 0, 10}; | 596 0, 0, 0, 0, 0, 0, 0, 10}; |
597 EXPECT_FALSE(IPAddressStartsWith(ipv6_address, ipv6_prefix5)); | 597 EXPECT_FALSE(IPAddressStartsWith(ipv6_address, ipv6_prefix5)); |
598 } | 598 } |
599 | 599 |
600 } // anonymous namespace | 600 } // anonymous namespace |
601 | 601 |
602 } // namespace net | 602 } // namespace net |
OLD | NEW |