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

Unified Diff: media/base/audio_video_metadata_extractor_unittest.cc

Issue 1643633005: Avoid dereferencing find() without checking for == end() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_video_metadata_extractor_unittest.cc
diff --git a/media/base/audio_video_metadata_extractor_unittest.cc b/media/base/audio_video_metadata_extractor_unittest.cc
index d67808f16eb6a4b792ba531593c00edc7d2a8911..fe57c3f6dae46dbcb311f2157a89c6a4e0f4b8dc 100644
--- a/media/base/audio_video_metadata_extractor_unittest.cc
+++ b/media/base/audio_video_metadata_extractor_unittest.cc
@@ -61,6 +61,16 @@ TEST(AudioVideoMetadataExtractorTest, AudioOGG) {
EXPECT_EQ(0u, extractor->attached_images_bytes().size());
}
+const std::string GetTagValue(
+ const media::AudioVideoMetadataExtractor::TagDictionary& tags,
+ const char* tag_name) {
+ auto tag_data = tags.find(tag_name);
+ EXPECT_NE(tag_data, tags.end());
DaleCurtis 2016/01/28 21:54:47 I'd just drop this since it's just noise in the te
brucedawson 2016/01/28 22:17:26 Sounds good. The original advice was to use ASSER
+ if (tag_data == tags.end())
+ return "";
+ return tag_data->second;
+}
+
TEST(AudioVideoMetadataExtractorTest, AudioWAV) {
scoped_ptr<AudioVideoMetadataExtractor> extractor =
GetExtractor("sfx_u8.wav", true, true, 0, -1, -1);
@@ -72,9 +82,9 @@ TEST(AudioVideoMetadataExtractorTest, AudioWAV) {
EXPECT_EQ(2u, extractor->stream_infos()[0].tags.size());
EXPECT_EQ("Lavf54.37.100",
- extractor->stream_infos()[0].tags.find("encoder")->second);
+ GetTagValue(extractor->stream_infos()[0].tags, "encoder"));
EXPECT_EQ("Amadeus Pro",
- extractor->stream_infos()[0].tags.find("encoded_by")->second);
+ GetTagValue(extractor->stream_infos()[0].tags, "encoded_by"));
EXPECT_EQ("pcm_u8", extractor->stream_infos()[1].type);
EXPECT_EQ(0u, extractor->stream_infos()[1].tags.size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698