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

Side by Side Diff: net/base/swr_histogram_domains/swr_histogram_domains_unittest.cc

Issue 1303973009: [DO NOT COMMIT] Re-use the dafsa code for s-w-r histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to fix patch errors on try bots. Created 5 years, 1 month 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
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/swr_histogram_domains/swr_histogram_domains.h"
6
7 #include <iosfwd>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace net {
12
13 namespace swr_histogram_domains {
14
15 namespace {
16
17 using ::testing::TestWithParam;
18 using ::testing::ValuesIn;
19
20 const struct Expectation {
21 const char* host;
22 bool result;
23 } kExpectations[] = {
24 {"wordpress.com", true},
25 {"issuu.com", true},
26 {"wordpress.com.", true},
27 {"www.wordpress.com", true},
28 {"www.wordpress.com.", true},
29 {"a.b.wordpress.com", true},
30 {"a.b.c.d.wordpress.com", true},
31 {"www..wordpress.com", true},
32 {"www.wordpress..com", false},
33 {"a-b-wordpress.com", false},
34 {"com", false},
35 {".", false},
36 {"", false},
37 {"..", false},
38 {"ordpress.com", false},
39 {"wordpress.co", false},
40 {"a", false},
41 {"a.b", false},
42 {"a.b.c", false},
43 {"a.b.c.d.e", false},
44 };
45
46 void PrintTo(const Expectation& expectation, std::ostream* os) {
47 *os << "{\"" << expectation.host << "\" ," << std::boolalpha
48 << expectation.result << "}";
49 }
50
51 class MatchTest : public TestWithParam<Expectation> {};
52
53 TEST_P(MatchTest, CheckExpectation) {
54 const Expectation& expectation = GetParam();
55 EXPECT_EQ(expectation.result, IsHostInSWRHistogramDomain(expectation.host));
56 }
57
58 INSTANTIATE_TEST_CASE_P(SwrHistogramDomainsTest,
59 MatchTest,
60 ValuesIn(kExpectations));
61
62 } // namespace
63
64 } // namespace swr_histogram_domains
65
66 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698