当前位置: 首页>>代码示例>>C++>>正文


C++ Maybe::AsString方法代码示例

本文整理汇总了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\")";
  }
}
开发者ID:,项目名称:,代码行数:35,代码来源:


注:本文中的Maybe::AsString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。