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

Unified Diff: Source/platform/weborigin/KnownPortsTest.cpp

Issue 1074913004: Simplify protocol name and port comparison in KnwonPorts.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: added upper-case test case Created 5 years, 8 months 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
« no previous file with comments | « Source/platform/weborigin/KnownPorts.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/weborigin/KnownPortsTest.cpp
diff --git a/Source/platform/weborigin/KnownPortsTest.cpp b/Source/platform/weborigin/KnownPortsTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e370cc1d1a8aa94673adb94414cbea5509c7ae7d
--- /dev/null
+++ b/Source/platform/weborigin/KnownPortsTest.cpp
@@ -0,0 +1,47 @@
+// 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 "config.h"
+#include "platform/weborigin/KnownPorts.h"
+
+#include <gtest/gtest.h>
+
+using blink::isDefaultPortForProtocol;
+
+namespace {
+
+TEST(KnownPortsTest, IsDefaultPortForProtocol)
+{
+ struct TestCase {
+ const unsigned short port;
+ const char* protocol;
+ const bool isKnown;
+ };
+
+ TestCase inputs[] = {
+ // Known ones.
+ { 80, "http", true },
+ { 443, "https", true },
+ { 21, "ftp", true },
+ { 990, "ftps", true },
+
+ // Unknown ones.
+ { 5, "foo", false },
+ { 80, "http:", false },
+ { 443, "http", false },
+ { 21, "ftps", false },
+ { 990, "ftp", false },
+
+ // With upper cases.
+ { 80, "HTTP", false },
+ { 443, "Https", false },
+ };
+
+ for (TestCase test : inputs) {
+ bool result = isDefaultPortForProtocol(test.port, test.protocol);
+ EXPECT_EQ(test.isKnown, result);
+ }
+}
+
+}
« no previous file with comments | « Source/platform/weborigin/KnownPorts.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698