本文整理汇总了C++中openstudio::decomposeDirectScaledUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::decomposeDirectScaledUnit方法的具体用法?C++ openstudio::decomposeDirectScaledUnit怎么用?C++ openstudio::decomposeDirectScaledUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio
的用法示例。
在下文中一共展示了openstudio::decomposeDirectScaledUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aMatch
TEST_F(UnitsFixture,QuantityRegex_DirectScaledUnit) {
// direct scaled unit
std::string aMatch("people/1000 ft^2");
EXPECT_TRUE(isDirectScaledUnit(aMatch));
aMatch = "1/10kg"; EXPECT_TRUE(isDirectScaledUnit(aMatch));
aMatch = "people/100*m^2"; EXPECT_TRUE(isDirectScaledUnit(aMatch));
// not a direct scaled unit
std::string notAMatch("m^2");
EXPECT_FALSE(isDirectScaledUnit(notAMatch));
notAMatch = "kg/10**m"; EXPECT_FALSE(isDirectScaledUnit(notAMatch));
// contains a direct scaled unit
std::string includesMatch("32 people/100 m^2");
EXPECT_TRUE(containsDirectScaledUnit(includesMatch));
boost::smatch m;
boost::regex_search(includesMatch,m,regexEmbeddedDirectScaledUnit());
std::string unitStr = std::string(m[1].first,m[1].second);
EXPECT_EQ("people/100 m^2",unitStr);
std::pair<std::string,std::pair<unsigned,std::string> > result;
result = decomposeDirectScaledUnit(unitStr);
EXPECT_EQ("people/",result.first);
EXPECT_EQ(static_cast<unsigned>(2),result.second.first);
EXPECT_EQ("m^2",result.second.second);
includesMatch = "Occupancy (people/1000*ft^2)";
EXPECT_TRUE(containsDirectScaledUnit(includesMatch));
boost::regex_search(includesMatch,m,regexEmbeddedDirectScaledUnit());
unitStr = std::string(m[5].first,m[5].second);
EXPECT_EQ("people/1000*ft^2",unitStr);
result = decomposeDirectScaledUnit(unitStr);
EXPECT_EQ("people/",result.first);
EXPECT_EQ(static_cast<unsigned>(3),result.second.first);
EXPECT_EQ("ft^2",result.second.second);
includesMatch = "1/10kg";
EXPECT_TRUE(containsDirectScaledUnit(includesMatch));
boost::regex_search(includesMatch,m,regexEmbeddedDirectScaledUnit());
unitStr = std::string(m[1].first,m[1].second);
EXPECT_EQ("1/10kg",unitStr);
result = decomposeDirectScaledUnit(unitStr);
EXPECT_EQ("1/",result.first);
EXPECT_EQ(static_cast<unsigned>(1),result.second.first);
EXPECT_EQ("kg",result.second.second);
}