OLD | NEW |
(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 "config.h" |
| 6 #include "platform/weborigin/KnownPorts.h" |
| 7 |
| 8 #include <gtest/gtest.h> |
| 9 |
| 10 using blink::isDefaultPortForProtocol; |
| 11 |
| 12 namespace { |
| 13 |
| 14 TEST(KnownPortsTest, IsDefaultPortForProtocol) |
| 15 { |
| 16 struct TestCase { |
| 17 const unsigned short port; |
| 18 const char* protocol; |
| 19 const bool isKnown; |
| 20 }; |
| 21 |
| 22 TestCase inputs[] = { |
| 23 // Known ones. |
| 24 { 80, "http", true }, |
| 25 { 443, "https", true }, |
| 26 { 21, "ftp", true }, |
| 27 { 990, "ftps", true }, |
| 28 |
| 29 // Unknown ones. |
| 30 { 5, "foo", false }, |
| 31 { 80, "http:", false }, |
| 32 { 443, "http", false }, |
| 33 { 21, "ftps", false }, |
| 34 { 990, "ftp", false }, |
| 35 |
| 36 // With upper cases. |
| 37 { 80, "HTTP", false }, |
| 38 { 443, "Https", false }, |
| 39 }; |
| 40 |
| 41 for (TestCase test : inputs) { |
| 42 bool result = isDefaultPortForProtocol(test.port, test.protocol); |
| 43 EXPECT_EQ(test.isKnown, result); |
| 44 } |
| 45 } |
| 46 |
| 47 } |
OLD | NEW |