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 |