mirror of https://github.com/aria2/aria2
2008-05-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed misuse of multimap::find() * src/HttpHeader.cc * test/HttpHeaderTest.ccpull/1/head
parent
d52bce74d3
commit
8fab8859b1
|
@ -59,8 +59,10 @@ std::string HttpHeader::getFirst(const std::string& name) const {
|
|||
|
||||
std::deque<std::string> HttpHeader::get(const std::string& name) const {
|
||||
std::deque<std::string> v;
|
||||
for(std::multimap<std::string, std::string>::const_iterator itr = table.find(Util::toLower(name)); itr != table.end(); itr++) {
|
||||
v.push_back((*itr).second);
|
||||
std::string n(Util::toLower(name));
|
||||
for(std::multimap<std::string, std::string>::const_iterator i = table.find(n);
|
||||
i != table.end() && (*i).first == n; ++i) {
|
||||
v.push_back((*i).second);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@ class HttpHeaderTest:public CppUnit::TestFixture {
|
|||
|
||||
CPPUNIT_TEST_SUITE(HttpHeaderTest);
|
||||
CPPUNIT_TEST(testGetRange);
|
||||
CPPUNIT_TEST(testGet);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testGetRange();
|
||||
|
||||
void testGet();
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,4 +45,17 @@ void HttpHeaderTest::testGetRange()
|
|||
}
|
||||
}
|
||||
|
||||
void HttpHeaderTest::testGet()
|
||||
{
|
||||
HttpHeader h;
|
||||
h.put("A", "100");
|
||||
h.put("a", "101");
|
||||
h.put("B", "200");
|
||||
|
||||
std::deque<std::string> r(h.get("A"));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, r.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("100"), r[0]);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("101"), r[1]);
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Reference in New Issue