OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/base/stale_while_revalidate_experiment_domains.h" |
| 6 |
| 7 #include <iosfwd> |
| 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace net { |
| 12 |
| 13 namespace { |
| 14 |
| 15 using ::testing::TestWithParam; |
| 16 using ::testing::ValuesIn; |
| 17 |
| 18 const struct Expectation { |
| 19 const char* host; |
| 20 bool result; |
| 21 } kExpectations[] = { |
| 22 {"wordpress.com", true}, |
| 23 {"issuu.com", true}, |
| 24 {"wordpress.com.", true}, |
| 25 {"www.wordpress.com", true}, |
| 26 {"www.wordpress.com.", true}, |
| 27 {"a.b.wordpress.com", true}, |
| 28 {"a.b.c.d.wordpress.com", true}, |
| 29 {"www..wordpress.com", true}, |
| 30 {"www.wordpress..com", false}, |
| 31 {"a-b-wordpress.com", false}, |
| 32 {"com", false}, |
| 33 {".", false}, |
| 34 {"", false}, |
| 35 {"..", false}, |
| 36 {"ordpress.com", false}, |
| 37 {"wordpress.co", false}, |
| 38 {"a", false}, |
| 39 {"a.b", false}, |
| 40 {"a.b.c", false}, |
| 41 {"a.b.c.d.e", false}, |
| 42 }; |
| 43 |
| 44 void PrintTo(const Expectation& expectation, std::ostream* os) { |
| 45 *os << "{\"" << expectation.host << "\" ," << std::boolalpha |
| 46 << expectation.result << "}"; |
| 47 } |
| 48 |
| 49 class MatchTest : public TestWithParam<Expectation> {}; |
| 50 |
| 51 TEST_P(MatchTest, CheckExpectation) { |
| 52 const Expectation& expectation = GetParam(); |
| 53 EXPECT_EQ(expectation.result, |
| 54 IsHostInStaleWhileRevalidateExperimentDomain(expectation.host)); |
| 55 } |
| 56 |
| 57 INSTANTIATE_TEST_CASE_P(StaleWhileRevalidateExperimentDomainsTest, |
| 58 MatchTest, |
| 59 ValuesIn(kExpectations)); |
| 60 |
| 61 } // namespace |
| 62 |
| 63 } // namespace net |
OLD | NEW |