OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/websockets/websocket_extension_parser.h" | 5 #include "net/websockets/websocket_extension_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "net/websockets/websocket_extension.h" | 9 #include "net/websockets/websocket_extension.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 expected.Add(WebSocketExtension::Parameter("bar", "baz")); | 58 expected.Add(WebSocketExtension::Parameter("bar", "baz")); |
59 expected.Add(WebSocketExtension::Parameter("hoge", "fuga")); | 59 expected.Add(WebSocketExtension::Parameter("hoge", "fuga")); |
60 | 60 |
61 parser.Parse("foo ; bar= baz;\t \thoge\t\t=fuga"); | 61 parser.Parse("foo ; bar= baz;\t \thoge\t\t=fuga"); |
62 | 62 |
63 ASSERT_FALSE(parser.has_error()); | 63 ASSERT_FALSE(parser.has_error()); |
64 EXPECT_TRUE(expected.Equals(parser.extension())); | 64 EXPECT_TRUE(expected.Equals(parser.extension())); |
65 } | 65 } |
66 | 66 |
67 TEST(WebSocketExtensionParserTest, InvalidPatterns) { | 67 TEST(WebSocketExtensionParserTest, InvalidPatterns) { |
68 const char* patterns[] = { | 68 const char* const patterns[] = { |
69 "fo\ao", // control in extension name | 69 "fo\ao", // control in extension name |
70 "fo\x01o", // control in extension name | 70 "fo\x01o", // control in extension name |
71 "fo<o", // separator in extension name | 71 "fo<o", // separator in extension name |
72 "foo/", // separator in extension name | 72 "foo/", // separator in extension name |
73 ";bar", // empty extension name | 73 ";bar", // empty extension name |
74 "foo bar", // missing ';' | 74 "foo bar", // missing ';' |
75 "foo;", // extension parameter without name and value | 75 "foo;", // extension parameter without name and value |
76 "foo; b\ar", // control in parameter name | 76 "foo; b\ar", // control in parameter name |
77 "foo; b\x7fr", // control in parameter name | 77 "foo; b\x7fr", // control in parameter name |
78 "foo; b[r", // separator in parameter name | 78 "foo; b[r", // separator in parameter name |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 parser.Parse("foo; bar = \"ba\\z\" "); | 114 parser.Parse("foo; bar = \"ba\\z\" "); |
115 | 115 |
116 ASSERT_FALSE(parser.has_error()); | 116 ASSERT_FALSE(parser.has_error()); |
117 EXPECT_TRUE(expected.Equals(parser.extension())); | 117 EXPECT_TRUE(expected.Equals(parser.extension())); |
118 } | 118 } |
119 | 119 |
120 } // namespace | 120 } // namespace |
121 | 121 |
122 } // namespace net | 122 } // namespace net |
OLD | NEW |