本文整理汇总了C++中openstudio::decomposeAtomicUnitString方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::decomposeAtomicUnitString方法的具体用法?C++ openstudio::decomposeAtomicUnitString怎么用?C++ openstudio::decomposeAtomicUnitString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio
的用法示例。
在下文中一共展示了openstudio::decomposeAtomicUnitString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: uStr
TEST_F(UnitsFixture,QuantityRegex_DecomposeAtomicUnits) {
std::string uStr("m");
std::pair<std::string,int> result;
result = decomposeAtomicUnitString(uStr);
EXPECT_EQ("m",result.first); EXPECT_EQ(1,result.second);
uStr = "kg^3"; result = decomposeAtomicUnitString(uStr);
EXPECT_EQ("kg",result.first); EXPECT_EQ(3,result.second);
uStr = "short^{-3291}"; result = decomposeAtomicUnitString(uStr);
EXPECT_EQ("short",result.first); EXPECT_EQ(-3291,result.second);
EXPECT_THROW(decomposeAtomicUnitString("kg^{2}"),openstudio::Exception);
EXPECT_THROW(decomposeAtomicUnitString("kg/s"),openstudio::Exception);
}
示例2: decomposeAtomicUnitString
TEST_F(UnitsFixture,QuantityRegex_PumpFields) {
std::string aUnit;
// Design Shaft Power per Unit Flow Rate per Unit Head is posing problems
// After trial and error, I can format the IDD so it works: No parenthesis, one divisor
// Currently this is the only one that passes
aUnit = "W*s/m^3*Pa"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "W*min/gal*ftH_{2}O"; EXPECT_TRUE(isUnit(aUnit));
std::pair<std::string,int> atomicDecomp;
aUnit = "ftH_{2}O";
// this shouldn't be an atomic unit!
// EXPECT_FALSE(isAtomicUnit(aUnit));
// But we can at least make sure that the decomposition at least returns the right exponent (1...)
atomicDecomp = decomposeAtomicUnitString(aUnit);
EXPECT_EQ("ftH_{2}O", atomicDecomp.first);
EXPECT_EQ(1, atomicDecomp.second);
aUnit = "1/ftH_{2}O";
EXPECT_FALSE(containsScientificNotationValue(aUnit));
// There is no multiplier (km, ms, etc)
// This returns TRUE, like above... but we'll make sure it ends up fine...
// EXPECT_FALSE(containsAtomicUnit(aUnit));
// 1 over something is a Compound Unit)
EXPECT_TRUE(containsCompoundUnit(aUnit));
EXPECT_FALSE(containsScaledUnit(aUnit));
EXPECT_FALSE(containsDirectScaledUnit(aUnit));
EXPECT_TRUE(isUnit(aUnit));
ASSERT_TRUE(isCompoundUnit(aUnit));
std::pair< std::vector<std::string>,std::vector<std::string> > result;
result = decomposeCompoundUnitString(aUnit);
// Nothing on numerator
ASSERT_EQ(static_cast<size_t>(0),result.first.size());
// Should have one unit on the denominator
ASSERT_EQ(static_cast<size_t>(1),result.second.size());
EXPECT_EQ("ftH_{2}O",result.second[0]);
// All of these variations do fail
/*
* aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
* aUnit = "(W*s)/(m^3*Pa)"; EXPECT_TRUE(isUnit(aUnit));
*
* aUnit = "(W*min)/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
* aUnit = "W*min/(gal*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
*
* aUnit = "W/((m^3/s)*Pa)"; EXPECT_TRUE(isUnit(aUnit));
* aUnit = "W/((gal/min)*ftH_{2}O)"; EXPECT_TRUE(isUnit(aUnit));
*/
}