本文整理汇总了C++中openstudio::isUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::isUnit方法的具体用法?C++ openstudio::isUnit怎么用?C++ openstudio::isUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio
的用法示例。
在下文中一共展示了openstudio::isUnit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
*/
}
示例2: atomicUnit
//.........这里部分代码省略.........
EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = " m/s^2"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "31"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "0.12 kg"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "hiccocampus"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "ft^^2"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "ft^{2}"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
notCompoundUnit = "ft/s,"; EXPECT_FALSE(isCompoundUnit(notCompoundUnit));
// contains compountUnit
std::string includesCompoundUnit("3 kg");
EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "3.0E-3 k(kg*m/s^2)"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "MJ"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "short words count, unfortunately"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "1 1/s"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "ft/s,"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
includesCompoundUnit = "J^2/s;"; EXPECT_TRUE(containsCompoundUnit(includesCompoundUnit));
// does not contain compoundUnit
std::string noCompoundUnitsHere("hippocampus");
EXPECT_FALSE(containsCompoundUnit(noCompoundUnitsHere));
noCompoundUnitsHere = "32,36819"; EXPECT_FALSE(containsCompoundUnit(noCompoundUnitsHere));
noCompoundUnitsHere = "389ft1986"; EXPECT_FALSE(containsCompoundUnit(noCompoundUnitsHere));
noCompoundUnitsHere = "ft^^2"; EXPECT_FALSE(containsCompoundUnit(noCompoundUnitsHere));
noCompoundUnitsHere = "ft^{2}"; EXPECT_FALSE(containsCompoundUnit(noCompoundUnitsHere));
// scaledUnit
std::string scaledUnit("k(m)");
EXPECT_TRUE(isScaledUnit(scaledUnit));
scaledUnit = "M(kg^3)"; EXPECT_TRUE(isScaledUnit(scaledUnit));
scaledUnit = "\\mu(ft^3/s^2)"; EXPECT_TRUE(isScaledUnit(scaledUnit));
scaledUnit = "aaaaa(kg^3)"; EXPECT_TRUE(isScaledUnit(scaledUnit));
scaledUnit = "M(1/s^2*K)"; EXPECT_TRUE(isScaledUnit(scaledUnit));
// not a scaledUnit
std::string notScaledUnit("m");
EXPECT_FALSE(isScaledUnit(notScaledUnit));
notScaledUnit = "1/s"; EXPECT_FALSE(isScaledUnit(notScaledUnit));
notScaledUnit = "k(m/s"; EXPECT_FALSE(isScaledUnit(notScaledUnit));
notScaledUnit = "\\mu\\mu(kg*m)"; EXPECT_FALSE(isScaledUnit(notScaledUnit));
notScaledUnit = "km^2)"; EXPECT_FALSE(isScaledUnit(notScaledUnit));
// contains a scaledUnit
std::string includesScaledUnit("3 M(kg^3/s^2*K)");
EXPECT_TRUE(containsScaledUnit(includesScaledUnit));
includesScaledUnit = ".1D-38 k(m)"; EXPECT_TRUE(containsScaledUnit(includesScaledUnit));
includesScaledUnit = "surrounding text 32 n(m^2/s) more text"; EXPECT_TRUE(containsScaledUnit(includesScaledUnit));
includesScaledUnit = "32 \\mu(W/s^2), is a funny quantity"; EXPECT_TRUE(containsScaledUnit(includesScaledUnit));
// does not contain a scaledUnit
std::string noScaledUnitsHere("3 m");
EXPECT_FALSE(containsScaledUnit(noScaledUnitsHere));
noScaledUnitsHere = "kg*m^2/s^2"; EXPECT_FALSE(containsScaledUnit(noScaledUnitsHere));
noScaledUnitsHere = "1200"; EXPECT_FALSE(containsScaledUnit(noScaledUnitsHere));
noScaledUnitsHere = "1.0E-2 MJ"; EXPECT_FALSE(containsScaledUnit(noScaledUnitsHere));
noScaledUnitsHere = "some text"; EXPECT_FALSE(containsScaledUnit(noScaledUnitsHere));
// unit
std::string aUnit("kg*m/s^2");
EXPECT_TRUE(isUnit(aUnit));
aUnit = "km/s"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "M(ft^3/s)"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "nJ"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "\\muN"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "s^{-3}/lb_m^{-2}*h"; EXPECT_TRUE(isUnit(aUnit));
aUnit = "ft*m^2*K/K*lb_f"; EXPECT_TRUE(isUnit(aUnit));
// not a unit
std::string notAUnit("(ft/s)");
EXPECT_FALSE(isUnit(notAUnit));
notAUnit = " kN"; EXPECT_FALSE(isUnit(notAUnit));
notAUnit = "m/s^2)"; EXPECT_FALSE(isUnit(notAUnit));
notAUnit = "kW^^2"; EXPECT_FALSE(isUnit(notAUnit));
notAUnit = "cm^-2"; EXPECT_FALSE(isUnit(notAUnit));
notAUnit = "2 m/s"; EXPECT_FALSE(isUnit(notAUnit));
notAUnit = "kg*2"; EXPECT_FALSE(isUnit(notAUnit));
// contains a unit
std::string includesAUnit("2 m");
EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = "3.2E-2 k(kg^2/s)"; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = " km/s "; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = "short, hairy elephant"; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = " 0.1 m \n 21.3 \\muN"; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = "km/s; "; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = "(ft/s) "; EXPECT_TRUE(containsUnit(includesAUnit));
includesAUnit = "Height [ft]"; EXPECT_TRUE(containsUnit(includesAUnit));
// does not contain a unit
std::string noUnitHere("2 m/s)");
EXPECT_FALSE(containsUnit(noUnitHere));
noUnitHere = "kN**ps/J"; EXPECT_FALSE(containsUnit(noUnitHere));
noUnitHere = "32 hippopotamuses"; EXPECT_FALSE(containsUnit(noUnitHere));
noUnitHere = "2.0 mph//J"; EXPECT_FALSE(containsUnit(noUnitHere));
noUnitHere = "2.0 m*2.0"; EXPECT_FALSE(containsUnit(noUnitHere));
}