本文整理汇总了C++中openstudio::containsScaledUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::containsScaledUnit方法的具体用法?C++ openstudio::containsScaledUnit怎么用?C++ openstudio::containsScaledUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio
的用法示例。
在下文中一共展示了openstudio::containsScaledUnit方法的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
TEST_F(UnitsFixture,QuantityRegex_Units) {
// should be AtomicUnits
std::string atomicUnit("kg");
EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "MJ"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "kBtu^3"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "s^{-1}"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "ms^5"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "aioranb^32"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "\\muN"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
atomicUnit = "lb_f^2"; EXPECT_TRUE(isAtomicUnit(atomicUnit));
// should not be AtomicUnits
std::string notAtomicUnit("m/s");
EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = " m "; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "kBtu/h"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "kg*m"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "3 s"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "kN*m"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "hippopotamus^3"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
notAtomicUnit = "ft^2,"; EXPECT_FALSE(isAtomicUnit(notAtomicUnit));
// should contain AtomicUnits
std::string includesUnit("kg*m");
EXPECT_TRUE(containsAtomicUnit(includesUnit));
includesUnit = "short words"; EXPECT_TRUE(containsAtomicUnit(includesUnit));
includesUnit = "kg^2/ms"; EXPECT_TRUE(containsAtomicUnit(includesUnit));
includesUnit = "hello s^{-2}"; EXPECT_TRUE(containsAtomicUnit(includesUnit));
// should not contain AtomicUnits
std::string doesNotContainUnit("kg^^3");
EXPECT_FALSE(containsAtomicUnit(doesNotContainUnit));
doesNotContainUnit = "3"; EXPECT_FALSE(containsAtomicUnit(doesNotContainUnit));
doesNotContainUnit = "m^-3"; EXPECT_FALSE(containsAtomicUnit(doesNotContainUnit));
doesNotContainUnit = "*2/"; EXPECT_FALSE(containsAtomicUnit(doesNotContainUnit));
// compoundUnits
std::string compoundUnit("kg/s");
EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "ft^2"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "1/s"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "1/s^2"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "kg*m^2/s^2"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "MJ^{-3}"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
compoundUnit = "s^{-1}/m^{-1}"; EXPECT_TRUE(isCompoundUnit(compoundUnit));
// not compoundUnits
std::string notCompoundUnit("k(kg/s)");
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));
//.........这里部分代码省略.........