Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/http/http_util.h" | 9 #include "net/http/http_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1171 std::string data = "name='value"; | 1171 std::string data = "name='value"; |
| 1172 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); | 1172 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); |
| 1173 EXPECT_TRUE(parser.valid()); | 1173 EXPECT_TRUE(parser.valid()); |
| 1174 | 1174 |
| 1175 ASSERT_NO_FATAL_FAILURE( | 1175 ASSERT_NO_FATAL_FAILURE( |
| 1176 CheckNextNameValuePair(&parser, true, true, "name", "value")); | 1176 CheckNextNameValuePair(&parser, true, true, "name", "value")); |
| 1177 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( | 1177 ASSERT_NO_FATAL_FAILURE(CheckNextNameValuePair( |
| 1178 &parser, false, true, std::string(), std::string())); | 1178 &parser, false, true, std::string(), std::string())); |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 TEST(HttpUtilTest, HasValidatorsHttp09) { | |
| 1182 std::string etags[] = {"", "\"strong\"", "W/\"weak\""}; | |
| 1183 std::string last_modified_values[] = {"", "Tue, 15 Nov 1994 12:45:26 GMT", | |
| 1184 "invalid"}; | |
| 1185 | |
| 1186 for (const std::string& etag : etags) { | |
| 1187 for (const std::string& last_modified : last_modified_values) { | |
| 1188 EXPECT_FALSE( | |
| 1189 HttpUtil::HasValidators(HttpVersion(0, 9), etag, last_modified)); | |
|
twifkak
2016/02/22 23:44:44
add `<< "with etag = " << etag << " and last_modif
jamartin
2016/02/23 14:03:35
I've applied your second suggestion, which obsolet
| |
| 1190 } | |
| 1191 } | |
|
twifkak
2016/02/22 23:44:44
There are 3*3=9 etag/last-modified pairs.
Suggest
jamartin
2016/02/23 14:03:35
Done.
There is one advantage of the loop approach
twifkak
2016/02/24 21:07:38
LGTM. Some rambling thoughts: Agreed, that the log
| |
| 1192 } | |
| 1193 | |
| 1194 TEST(HttpUtilTest, HasValidatorsHttp10) { | |
| 1195 std::string etags[] = {"", "\"strong\"", "W/\"weak\""}; | |
| 1196 std::string last_modified_values[] = {"", "Tue, 15 Nov 1994 12:45:26 GMT", | |
| 1197 "invalid"}; | |
| 1198 | |
| 1199 for (const std::string& etag : etags) { | |
| 1200 for (const std::string& last_modified : last_modified_values) { | |
| 1201 EXPECT_EQ( | |
| 1202 last_modified != "" && last_modified != "invalid", | |
| 1203 HttpUtil::HasValidators(HttpVersion(1, 0), etag, last_modified)); | |
| 1204 } | |
| 1205 } | |
| 1206 } | |
| 1207 | |
| 1208 TEST(HttpUtilTest, HasValidatorsHttp11) { | |
| 1209 std::string etags[] = {"", "\"strong\"", "W/\"weak\""}; | |
| 1210 std::string last_modified_values[] = {"", "Tue, 15 Nov 1994 12:45:26 GMT", | |
| 1211 "invalid"}; | |
| 1212 | |
| 1213 for (const std::string& etag : etags) { | |
| 1214 for (const std::string& last_modified : last_modified_values) { | |
| 1215 EXPECT_EQ( | |
| 1216 etag != "" || (last_modified != "" && last_modified != "invalid"), | |
| 1217 HttpUtil::HasValidators(HttpVersion(1, 1), etag, last_modified)); | |
| 1218 } | |
| 1219 } | |
| 1220 } | |
| 1221 | |
| 1181 } // namespace net | 1222 } // namespace net |
| OLD | NEW |