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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/base/swr_histogram_domains/swr_histogram_domains_unittest.cc
diff --git a/net/base/swr_histogram_domains/swr_histogram_domains_unittest.cc b/net/base/swr_histogram_domains/swr_histogram_domains_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c86d2aa39ec599558d84d6d95caac06d8329461f
--- /dev/null
+++ b/net/base/swr_histogram_domains/swr_histogram_domains_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/swr_histogram_domains/swr_histogram_domains.h"
+
+#include <iosfwd>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace swr_histogram_domains {
+
+namespace {
+
+using ::testing::TestWithParam;
+using ::testing::ValuesIn;
+
+const struct Expectation {
+ const char* host;
+ bool result;
+} kExpectations[] = {
+ {"wordpress.com", true},
+ {"issuu.com", true},
+ {"wordpress.com.", true},
+ {"www.wordpress.com", true},
+ {"www.wordpress.com.", true},
+ {"a.b.wordpress.com", true},
+ {"a.b.c.d.wordpress.com", true},
+ {"www..wordpress.com", true},
+ {"www.wordpress..com", false},
+ {"a-b-wordpress.com", false},
+ {"com", false},
+ {".", false},
+ {"", false},
+ {"..", false},
+ {"ordpress.com", false},
+ {"wordpress.co", false},
+ {"a", false},
+ {"a.b", false},
+ {"a.b.c", false},
+ {"a.b.c.d.e", false},
+};
+
+void PrintTo(const Expectation& expectation, std::ostream* os) {
+ *os << "{\"" << expectation.host << "\" ," << std::boolalpha
+ << expectation.result << "}";
+}
+
+class MatchTest : public TestWithParam<Expectation> {};
+
+TEST_P(MatchTest, CheckExpectation) {
+ const Expectation& expectation = GetParam();
+ EXPECT_EQ(expectation.result, IsHostInSWRHistogramDomain(expectation.host));
+}
+
+INSTANTIATE_TEST_CASE_P(SwrHistogramDomainsTest,
+ MatchTest,
+ ValuesIn(kExpectations));
+
+} // namespace
+
+} // namespace swr_histogram_domains
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698