| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/host_mapping_rules.h" | 5 #include "net/base/host_mapping_rules.h" |
| 6 | 6 |
| 7 #include "net/base/host_port_pair.h" | 7 #include "net/base/host_port_pair.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 EXPECT_FALSE(rules.RewriteHost(&host_port)); | 65 EXPECT_FALSE(rules.RewriteHost(&host_port)); |
| 66 EXPECT_EQ("wtf.foo.com", host_port.host()); | 66 EXPECT_EQ("wtf.foo.com", host_port.host()); |
| 67 EXPECT_EQ(443u, host_port.port()); | 67 EXPECT_EQ(443u, host_port.port()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Parsing bad rules should silently discard the rule (and never crash). | 70 // Parsing bad rules should silently discard the rule (and never crash). |
| 71 TEST(HostMappingRulesTest, ParseInvalidRules) { | 71 TEST(HostMappingRulesTest, ParseInvalidRules) { |
| 72 HostMappingRules rules; | 72 HostMappingRules rules; |
| 73 | 73 |
| 74 EXPECT_FALSE(rules.AddRuleFromString("xyz")); | 74 EXPECT_FALSE(rules.AddRuleFromString("xyz")); |
| 75 EXPECT_FALSE(rules.AddRuleFromString("")); | 75 EXPECT_FALSE(rules.AddRuleFromString(std::string())); |
| 76 EXPECT_FALSE(rules.AddRuleFromString(" ")); | 76 EXPECT_FALSE(rules.AddRuleFromString(" ")); |
| 77 EXPECT_FALSE(rules.AddRuleFromString("EXCLUDE")); | 77 EXPECT_FALSE(rules.AddRuleFromString("EXCLUDE")); |
| 78 EXPECT_FALSE(rules.AddRuleFromString("EXCLUDE foo bar")); | 78 EXPECT_FALSE(rules.AddRuleFromString("EXCLUDE foo bar")); |
| 79 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE")); | 79 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE")); |
| 80 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE x")); | 80 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE x")); |
| 81 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE x :10")); | 81 EXPECT_FALSE(rules.AddRuleFromString("INCLUDE x :10")); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 } // namespace net | 86 } // namespace net |
| OLD | NEW |