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


C++ Bundle::getBlocks方法代码示例

本文整理汇总了C++中Bundle::getBlocks方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::getBlocks方法的具体用法?C++ Bundle::getBlocks怎么用?C++ Bundle::getBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bundle的用法示例。


在下文中一共展示了Bundle::getBlocks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Bundle

/**
 * Check the constructor with parameters.
 * The primary block must contain the source and the destination.
 * The bundle must contain a payloadBlock with the payload value.
 */
TEST(BundleTest, FilledConstructor) {
  Bundle b = Bundle("source", "destination", "payload");
  ASSERT_EQ("source", b.getPrimaryBlock()->getSource());
  ASSERT_EQ("destination", b.getPrimaryBlock()->getDestination());
  ASSERT_EQ(static_cast<uint8_t>(2), b.getBlocks().size());
  ASSERT_EQ(static_cast<uint8_t>(CanonicalBlockTypes::PAYLOAD_BLOCK),
            b.getPayloadBlock()->getBlockType());
}
开发者ID:SeNDA-UAB,项目名称:aDTNPlus,代码行数:13,代码来源:BundleTest.cpp

示例2: CanonicalBlock

/**
 * Check the raw functions when a canonical block is added.
 * Generate a bundle, add a valid canonical block, convert all to raw.
 * Create a new bundle from that raw, check that all the blocks are correct.
 */
TEST(BundleTest, ConstructorWithCanonical) {
  Bundle b = Bundle("Source", "Destination", "This is a payload");
  std::stringstream ss;
  // Block Type
  ss << static_cast<uint8_t>(2) << SDNV::encode(std::bitset<7>().to_ulong());
  std::string data = std::to_string(rand() + 1);
  ss << SDNV::encode(data.size()) << data;
  std::shared_ptr<CanonicalBlock> cb = std::shared_ptr<CanonicalBlock>(
      new CanonicalBlock(ss.str()));
  ASSERT_EQ(ss.str(), cb->toRaw());
  b.addBlock(cb);
  ASSERT_EQ(static_cast<uint8_t>(3), b.getBlocks().size());
  std::string raw = b.toRaw();
  Bundle b1 = Bundle(raw);
  ASSERT_EQ(b.getBlocks().size(), b1.getBlocks().size());
  std::shared_ptr<CanonicalBlock> cb1 =
      std::static_pointer_cast<CanonicalBlock>(b1.getBlocks()[2]);
  ASSERT_EQ(cb->toRaw(), cb1->toRaw());
  ASSERT_EQ(cb->getBlockType(), cb1->getBlockType());
}
开发者ID:SeNDA-UAB,项目名称:aDTNPlus,代码行数:25,代码来源:BundleTest.cpp


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