TEST(MediaMIMETypes, MediaMIMEType) { static const struct { const char* mTypeString; const char* mAsString; bool mApplication; bool mAudio; bool mVideo; bool mEqualsLiteralVideoSlashMp4; // tests `== "video/mp4"` } tests[] = { // in AsString app audio video ==v/mp4 { "video/mp4", "video/mp4", false, false, true, true }, { "video/mp4; codecs=0", "video/mp4", false, false, true, true }, { "VIDEO/MP4", "video/mp4", false, false, true, true }, { "audio/mp4", "audio/mp4", false, true, false, false }, { "application/x", "application/x", true, false, false, false } }; for (const auto& test : tests) { Maybe<MediaMIMEType> type = MakeMediaMIMEType(test.mTypeString); EXPECT_TRUE(type.isSome()) << "MakeMediaMIMEType(\"" << test.mTypeString << "\").isSome()"; EXPECT_TRUE(type->AsString().EqualsASCII(test.mAsString)) << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mAsString << "\""; EXPECT_EQ(test.mApplication, type->HasApplicationMajorType()) << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasApplicationMajorType() == " << (test.mApplication ? "true" : "false"); EXPECT_EQ(test.mAudio, type->HasAudioMajorType()) << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasAudioMajorType() == " << (test.mAudio ? "true" : "false"); EXPECT_EQ(test.mVideo, type->HasVideoMajorType()) << "MakeMediaMIMEType(\"" << test.mTypeString << "\")->HasVideoMajorType() == " << (test.mVideo ? "true" : "false"); EXPECT_EQ(test.mEqualsLiteralVideoSlashMp4, *type == MEDIAMIMETYPE("video/mp4")) << "*MakeMediaMIMEType(\"" << test.mTypeString << "\") == MEDIAMIMETYPE(\"video/mp4\")"; } }