Fix duplicate entries in CefRequest header map (issue #1840)

This commit is contained in:
Marshall Greenblatt
2016-03-01 18:59:53 -05:00
parent 1b7c5303ce
commit e1aa8cc109
3 changed files with 30 additions and 7 deletions

View File

@@ -8,11 +8,15 @@
#include "tests/unittests/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
void TestMapEqual(CefRequest::HeaderMap& map1,
CefRequest::HeaderMap& map2,
void TestMapEqual(const CefRequest::HeaderMap& map1,
const CefRequest::HeaderMap& map2,
bool allowExtras) {
if (!allowExtras)
EXPECT_EQ(map1.size(), map2.size());
TestMapNoDuplicates(map1);
TestMapNoDuplicates(map2);
CefRequest::HeaderMap::const_iterator it1, it2;
for (it1 = map1.begin(); it1 != map1.end(); ++it1) {
@@ -25,6 +29,17 @@ void TestMapEqual(CefRequest::HeaderMap& map1,
}
}
void TestMapNoDuplicates(const CefRequest::HeaderMap& map) {
CefRequest::HeaderMap::const_iterator it1 = map.begin();
for (; it1 != map.end(); ++it1) {
CefRequest::HeaderMap::const_iterator it2 = it1;
for (++it2; it2 != map.end(); ++it2) {
EXPECT_FALSE(it1->first == it2->first && it1->second == it2->second) <<
"Duplicate entry for " << it1->first << ": " << it1->second;
}
}
}
void TestPostDataElementEqual(CefRefPtr<CefPostDataElement> elem1,
CefRefPtr<CefPostDataElement> elem2) {
EXPECT_TRUE(elem1.get());