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


C++ Attributes::get方法代码示例

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


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

示例1: exec

// Test that the changes made by the resources decorator hook are correctly
// propagated to the resource offer.
TEST_F(HookTest, VerifySlaveResourcesAndAttributesDecorator)
{
  Try<PID<Master>> master = StartMaster(CreateMasterFlags());
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);

  TestContainerizer containerizer(&exec);

  // Start a mock slave since we aren't testing the slave hooks yet.
  Try<PID<Slave>> slave = StartSlave(&containerizer);
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
    &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  EXPECT_NE(0u, offers.get().size());

  Resources resources = offers.get()[0].resources();

  // The test hook sets "cpus" to 4.
  EXPECT_EQ(4, resources.cpus().get());

  // The test hook adds a resource named "foo" of type set with values "bar"
  // and "baz".
  EXPECT_EQ(Resources::parse("foo:{bar,baz}").get(), resources.get("foo"));

  // The test hook does not modify "mem", the default value must still be
  // present.
  EXPECT_SOME(resources.mem());

  // The test hook adds an attribute named "rack" with value "rack1".
  Attributes attributes = offers.get()[0].attributes();
  ASSERT_EQ(attributes.get(0).name(), "rack");
  ASSERT_EQ(attributes.get(0).text().value(), "rack1");

  driver.stop();
  driver.join();

  Shutdown();
}
开发者ID:lodejard,项目名称:mesoswin,代码行数:54,代码来源:hook_tests.cpp

示例2:

TEST(AttributesTest, invalid_attrib_is_ignored)
{
    string s = "default";
    Attributes a;
    a.addFromGFF("foo");
    EXPECT_FALSE(a.get("foo", s));
    EXPECT_EQ("default", s);
}
开发者ID:abuchanan,项目名称:duncan,代码行数:8,代码来源:Attributes.cpp

示例3:

TEST(AttributesTest, Parsing)
{
  Attributes a = Attributes::parse("cpus:45.55;"
                                   "ports:[10000-20000, 30000-50000];"
                                   "rack:rack1,rack2");
  ASSERT_EQ(Value::SCALAR, a.get(0).type());
  ASSERT_EQ("cpus", a.get(0).name());
  ASSERT_FLOAT_EQ(45.55, a.get(0).scalar().value());

  ASSERT_EQ(Value::RANGES, a.get(1).type());
  ASSERT_EQ("ports", a.get(1).name());
  ASSERT_EQ(2, a.get(1).ranges().range_size());
  ASSERT_EQ(10000u, a.get(1).ranges().range(0).begin());
  ASSERT_EQ(20000u, a.get(1).ranges().range(0).end());
  ASSERT_EQ(30000u, a.get(1).ranges().range(1).begin());
  ASSERT_EQ(50000u, a.get(1).ranges().range(1).end());


  ASSERT_EQ(Value::TEXT, a.get(2).type());
  ASSERT_EQ("rack", a.get(2).name());
  ASSERT_EQ("rack1,rack2", a.get(2).text().value());

  Attributes b = Attributes::parse("attr1:foo:bar;attr2:baz:qux:");
  ASSERT_EQ(Value::TEXT, b.get(0).type());
  ASSERT_EQ("attr1", b.get(0).name());
  ASSERT_EQ("foo:bar", b.get(0).text().value());
  ASSERT_EQ(Value::TEXT, b.get(1).type());
  ASSERT_EQ("attr2", b.get(1).name());
  ASSERT_EQ("baz:qux:", b.get(1).text().value());
}
开发者ID:lins05,项目名称:mesos,代码行数:30,代码来源:attributes_tests.cpp


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