Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Side by Side Diff: net/base/stale_while_revalidate_experiment_domains_unittest.cc

Issue 1433893002: Add StaleWhileRevalidateExperiment histograms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s-w-r-dafsa
Patch Set: Fix compile error. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/stale_while_revalidate_experiment_domains.gperf ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « net/base/stale_while_revalidate_experiment_domains.gperf ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698