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


C++ openstudio::decomposeQuantityString方法代码示例

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


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

示例1: qStr

TEST_F(UnitsFixture,QuantityRegex_DecomposeQuantities) {
  std::string qStr("3 m");
  std::pair<std::string,std::string> result;
  
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("3",result.first); EXPECT_EQ("m",result.second);

  qStr = "-.1D-3 kg*m/s^2";
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("-.1D-3",result.first); EXPECT_EQ("kg*m/s^2",result.second);

  qStr = "3200 lb_f/s^2";
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("3200",result.first); EXPECT_EQ("lb_f/s^2",result.second);

  qStr = "3.01E2 M(lb_m*kg/K*s)";
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("3.01E2",result.first); EXPECT_EQ("M(lb_m*kg/K*s)",result.second);

  qStr = "21 shorts";
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("21",result.first); EXPECT_EQ("shorts",result.second);

  qStr = "0.0002658928196837 kN";
  result = decomposeQuantityString(qStr);
  EXPECT_EQ("0.0002658928196837",result.first); EXPECT_EQ("kN",result.second);

  EXPECT_THROW(decomposeQuantityString("A nice, short sentence."),openstudio::Exception);
  EXPECT_THROW(decomposeQuantityString("5 m."),openstudio::Exception);
  EXPECT_THROW(decomposeQuantityString("2.0kg*m"),openstudio::Exception);
  EXPECT_THROW(decomposeQuantityString("9.12E-32 lb_f/s)"),openstudio::Exception);
  EXPECT_THROW(decomposeQuantityString("t3.0 s"),openstudio::Exception);
  EXPECT_THROW(decomposeQuantityString("5,000 W/m^2"),openstudio::Exception);
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:34,代码来源:QuantityRegex_GTest.cpp


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