Don't implicitly construct StringPiece from nullptr

This change implements the crashpad changes from
https://crrev.com/c/2027791 upstream.

Bug: chromium:1049498
Change-Id: I59b920d878b080d41db32bf0305d3d8f3d4f47c9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2042712
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Jan Wilken Dörrie 2020-02-07 15:05:21 +01:00 committed by Commit Bot
parent 5779e638e1
commit 52ddeac77c

View File

@ -73,7 +73,7 @@ TEST(SimpleStringDictionary, SimpleStringDictionary) {
EXPECT_FALSE(dict.GetValueForKey("key3"));
// Remove by setting value to nullptr
dict.SetKeyValue("key2", nullptr);
dict.SetKeyValue("key2", base::StringPiece(nullptr, 0));
// Now make sure it's not there anymore
EXPECT_FALSE(dict.GetValueForKey("key2"));
@ -254,13 +254,14 @@ TEST(SimpleStringDictionary, OutOfSpace) {
TEST(SimpleStringDictionaryDeathTest, SetKeyValueWithNullKey) {
TSimpleStringDictionary<4, 6, 6> map;
ASSERT_DEATH_CHECK(map.SetKeyValue(nullptr, "hello"), "key");
ASSERT_DEATH_CHECK(map.SetKeyValue(base::StringPiece(nullptr, 0), "hello"),
"key");
}
TEST(SimpleStringDictionaryDeathTest, GetValueForKeyWithNullKey) {
TSimpleStringDictionary<4, 6, 6> map;
map.SetKeyValue("hi", "there");
ASSERT_DEATH_CHECK(map.GetValueForKey(nullptr), "key");
ASSERT_DEATH_CHECK(map.GetValueForKey(base::StringPiece(nullptr, 0)), "key");
EXPECT_STREQ("there", map.GetValueForKey("hi"));
}