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

Side by Side Diff: net/quic/core/quic_spdy_stream_test.cc

Issue 2558643002: Remove some uses of isdigit in net/, as it can be locale depedent. (Closed)
Patch Set: Response Created 4 years 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/core/quic_spdy_stream.cc ('k') | net/spdy/spdy_alt_svc_wire_format.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 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/quic/core/quic_spdy_stream.h" 5 #include "net/quic/core/quic_spdy_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 EXPECT_FALSE(stream_->IsDoneReading()); 172 EXPECT_FALSE(stream_->IsDoneReading());
173 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); 173 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset());
174 } 174 }
175 175
176 TEST_P(QuicSpdyStreamTest, ParseHeaderStatusCode) { 176 TEST_P(QuicSpdyStreamTest, ParseHeaderStatusCode) {
177 // A valid status code should be 3-digit integer. The first digit should be in 177 // A valid status code should be 3-digit integer. The first digit should be in
178 // the range of [1, 5]. All the others are invalid. 178 // the range of [1, 5]. All the others are invalid.
179 Initialize(kShouldProcessData); 179 Initialize(kShouldProcessData);
180 int status_code = 0; 180 int status_code = 0;
181 181
182 // Valid status code. 182 // Valid status codes.
183 headers_[":status"] = "404"; 183 headers_[":status"] = "404";
184 EXPECT_TRUE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 184 EXPECT_TRUE(stream_->ParseHeaderStatusCode(headers_, &status_code));
185 EXPECT_EQ(404, status_code); 185 EXPECT_EQ(404, status_code);
186 186
187 headers_[":status"] = "100";
188 EXPECT_TRUE(stream_->ParseHeaderStatusCode(headers_, &status_code));
189 EXPECT_EQ(100, status_code);
190
191 headers_[":status"] = "599";
192 EXPECT_TRUE(stream_->ParseHeaderStatusCode(headers_, &status_code));
193 EXPECT_EQ(599, status_code);
194
187 // Invalid status codes. 195 // Invalid status codes.
188 headers_[":status"] = "010"; 196 headers_[":status"] = "010";
189 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 197 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
190 198
191 headers_[":status"] = "600"; 199 headers_[":status"] = "600";
192 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 200 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
193 201
194 headers_[":status"] = "200 ok"; 202 headers_[":status"] = "200 ok";
195 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 203 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
196 204
197 headers_[":status"] = "2000"; 205 headers_[":status"] = "2000";
198 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 206 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
199 207
200 headers_[":status"] = "+200"; 208 headers_[":status"] = "+200";
201 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 209 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
202 210
203 headers_[":status"] = "+20"; 211 headers_[":status"] = "+20";
204 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 212 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
205 213
214 headers_[":status"] = "-10";
215 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
216
217 headers_[":status"] = "-100";
218 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
219
206 // Leading or trailing spaces are also invalid. 220 // Leading or trailing spaces are also invalid.
207 headers_[":status"] = " 200"; 221 headers_[":status"] = " 200";
208 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 222 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
209 223
210 headers_[":status"] = "200 "; 224 headers_[":status"] = "200 ";
211 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 225 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
212 226
213 headers_[":status"] = " 200 "; 227 headers_[":status"] = " 200 ";
214 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code)); 228 EXPECT_FALSE(stream_->ParseHeaderStatusCode(headers_, &status_code));
215 229
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 939
926 // Writing Trailers should fail, as the FIN has already been sent. 940 // Writing Trailers should fail, as the FIN has already been sent.
927 // populated with the number of body bytes written. 941 // populated with the number of body bytes written.
928 EXPECT_QUIC_BUG(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), 942 EXPECT_QUIC_BUG(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr),
929 "Trailers cannot be sent after a FIN"); 943 "Trailers cannot be sent after a FIN");
930 } 944 }
931 945
932 } // namespace 946 } // namespace
933 } // namespace test 947 } // namespace test
934 } // namespace net 948 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_spdy_stream.cc ('k') | net/spdy/spdy_alt_svc_wire_format.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698