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

Side by Side Diff: net/http/http_util_unittest.cc

Issue 276067: Adding support for Reset in StringTokenizerT and HttpHeadersIterator.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_util.h ('k') | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n"); 99 HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n");
100 EXPECT_TRUE(it.AdvanceTo("foo")); 100 EXPECT_TRUE(it.AdvanceTo("foo"));
101 EXPECT_EQ("foo", it.name()); 101 EXPECT_EQ("foo", it.name());
102 EXPECT_TRUE(it.AdvanceTo("bar")); 102 EXPECT_TRUE(it.AdvanceTo("bar"));
103 EXPECT_EQ("bar", it.name()); 103 EXPECT_EQ("bar", it.name());
104 EXPECT_FALSE(it.AdvanceTo("blat")); 104 EXPECT_FALSE(it.AdvanceTo("blat"));
105 EXPECT_FALSE(it.GetNext()); // should be at end of headers 105 EXPECT_FALSE(it.GetNext()); // should be at end of headers
106 } 106 }
107 107
108 TEST(HttpUtilTest, HeadersIterator_Reset) {
109 std::string headers = "foo: 1\r\n: 2\r\n3\r\nbar: 4";
110 HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n");
111 // Search past "foo".
112 EXPECT_TRUE(it.AdvanceTo("bar"));
113 // Now try advancing to "foo". This time it should fail since the iterator
114 // position is past it.
115 EXPECT_FALSE(it.AdvanceTo("foo"));
116 it.Reset();
117 // Now that we reset the iterator position, we should find 'foo'
118 EXPECT_TRUE(it.AdvanceTo("foo"));
119 }
120
108 TEST(HttpUtilTest, ValuesIterator) { 121 TEST(HttpUtilTest, ValuesIterator) {
109 std::string values = " must-revalidate, no-cache=\"foo, bar\"\t, private "; 122 std::string values = " must-revalidate, no-cache=\"foo, bar\"\t, private ";
110 123
111 HttpUtil::ValuesIterator it(values.begin(), values.end(), ','); 124 HttpUtil::ValuesIterator it(values.begin(), values.end(), ',');
112 125
113 ASSERT_TRUE(it.GetNext()); 126 ASSERT_TRUE(it.GetNext());
114 EXPECT_EQ(std::string("must-revalidate"), it.value()); 127 EXPECT_EQ(std::string("must-revalidate"), it.value());
115 128
116 ASSERT_TRUE(it.GetNext()); 129 ASSERT_TRUE(it.GetNext());
117 EXPECT_EQ(std::string("no-cache=\"foo, bar\""), it.value()); 130 EXPECT_EQ(std::string("no-cache=\"foo, bar\""), it.value());
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 EXPECT_EQ(tests[i].expected_ranges[j].expected_first_byte_position, 664 EXPECT_EQ(tests[i].expected_ranges[j].expected_first_byte_position,
652 ranges[j].first_byte_position()); 665 ranges[j].first_byte_position());
653 EXPECT_EQ(tests[i].expected_ranges[j].expected_last_byte_position, 666 EXPECT_EQ(tests[i].expected_ranges[j].expected_last_byte_position,
654 ranges[j].last_byte_position()); 667 ranges[j].last_byte_position());
655 EXPECT_EQ(tests[i].expected_ranges[j].expected_suffix_length, 668 EXPECT_EQ(tests[i].expected_ranges[j].expected_suffix_length,
656 ranges[j].suffix_length()); 669 ranges[j].suffix_length());
657 } 670 }
658 } 671 }
659 } 672 }
660 } 673 }
OLDNEW
« no previous file with comments | « net/http/http_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698