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

Side by Side Diff: net/quic/platform/api/quic_hostname_utils_test.cc

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « net/quic/platform/api/quic_endian_test.cc ('k') | net/quic/platform/api/quic_lru_cache_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/platform/api/quic_hostname_utils.h" 5 #include "net/quic/platform/api/quic_hostname_utils.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "net/quic/platform/api/quic_test.h"
8 8
9 using std::string; 9 using std::string;
10 10
11 namespace net { 11 namespace net {
12 namespace test { 12 namespace test {
13 namespace { 13 namespace {
14 14
15 TEST(QuicHostnameUtilsTest, IsValidSNI) { 15 class QuicHostnameUtilsTest : public QuicTest {};
16
17 TEST_F(QuicHostnameUtilsTest, IsValidSNI) {
16 // IP as SNI. 18 // IP as SNI.
17 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI("192.168.0.1")); 19 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI("192.168.0.1"));
18 // SNI without any dot. 20 // SNI without any dot.
19 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI("somedomain")); 21 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI("somedomain"));
20 // Invalid by RFC2396 but unfortunately domains of this form exist. 22 // Invalid by RFC2396 but unfortunately domains of this form exist.
21 EXPECT_TRUE(QuicHostnameUtils::IsValidSNI("some_domain.com")); 23 EXPECT_TRUE(QuicHostnameUtils::IsValidSNI("some_domain.com"));
22 // An empty string must be invalid otherwise the QUIC client will try sending 24 // An empty string must be invalid otherwise the QUIC client will try sending
23 // it. 25 // it.
24 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI("")); 26 EXPECT_FALSE(QuicHostnameUtils::IsValidSNI(""));
25 27
26 // Valid SNI 28 // Valid SNI
27 EXPECT_TRUE(QuicHostnameUtils::IsValidSNI("test.google.com")); 29 EXPECT_TRUE(QuicHostnameUtils::IsValidSNI("test.google.com"));
28 } 30 }
29 31
30 TEST(QuicHostnameUtilsTest, NormalizeHostname) { 32 TEST_F(QuicHostnameUtilsTest, NormalizeHostname) {
31 struct { 33 struct {
32 const char *input, *expected; 34 const char *input, *expected;
33 } tests[] = { 35 } tests[] = {
34 { 36 {
35 "www.google.com", "www.google.com", 37 "www.google.com", "www.google.com",
36 }, 38 },
37 { 39 {
38 "WWW.GOOGLE.COM", "www.google.com", 40 "WWW.GOOGLE.COM", "www.google.com",
39 }, 41 },
40 { 42 {
(...skipping 14 matching lines...) Expand all
55 char buf[256]; 57 char buf[256];
56 snprintf(buf, sizeof(buf), "%s", tests[i].input); 58 snprintf(buf, sizeof(buf), "%s", tests[i].input);
57 EXPECT_EQ(string(tests[i].expected), 59 EXPECT_EQ(string(tests[i].expected),
58 QuicHostnameUtils::NormalizeHostname(buf)); 60 QuicHostnameUtils::NormalizeHostname(buf));
59 } 61 }
60 } 62 }
61 63
62 } // namespace 64 } // namespace
63 } // namespace test 65 } // namespace test
64 } // namespace net 66 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/platform/api/quic_endian_test.cc ('k') | net/quic/platform/api/quic_lru_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698