本文整理汇总了C++中Maybe::AsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Maybe::AsString方法的具体用法?C++ Maybe::AsString怎么用?C++ Maybe::AsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maybe
的用法示例。
在下文中一共展示了Maybe::AsString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeMediaMIMEType
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\")";
}
}