本文整理汇总了C++中Quantity::prettyUnitsString方法的典型用法代码示例。如果您正苦于以下问题:C++ Quantity::prettyUnitsString方法的具体用法?C++ Quantity::prettyUnitsString怎么用?C++ Quantity::prettyUnitsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quantity
的用法示例。
在下文中一共展示了Quantity::prettyUnitsString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: len
TEST_F(UnitsFixture,Quantity_ArithmeticOperators)
{
LOG(Debug,"Quantity_ArithmeticOperators");
Quantity q1;
Quantity q2(1.0);
Unit u3;
u3.setBaseUnitExponent("ft",1);
Quantity q3(34.2,u3);
// addition
Quantity q4 = q1 + q2;
q4 += q4;
testNumbersEqual(2.0,q4.value());
testStreamOutput("2",q4);
ASSERT_THROW(q3 + q1,Exception);
// subtraction;
ASSERT_THROW(q3 - q1,Exception);
Quantity len(3.5,u3);
len -= q3;
testNumbersEqual(-30.7,len.value());
testStreamOutput("-30.7 ft",len,1);
// multiplication
q3 *= q4;
testNumbersEqual(68.4,q3.value());
testStreamOutput("68.4 ft",q3,1);
Unit u5;
u5.setBaseUnitExponent("s",-2);
u5.setBaseUnitExponent("ft",1);
Quantity q5(0.5,u5);
Quantity q6 = q5 * q3;
testNumbersEqual(34.2,q6.value());
testStreamOutput("34.2 ft^2/s^2",q6,1);
// division
len = Quantity(1.1,u3);
Quantity a = q6/len;
testNumbersEqual(31.0909090909,a.value());
EXPECT_EQ("ft/s^2",a.standardUnitsString());
// pow
a.pow(6);
EXPECT_EQ("ft^6/s^12",a.standardUnitsString());
Quantity b = openstudio::pow(a,1,3);
EXPECT_EQ("ft^2/s^4",b.standardUnitsString());
testNumbersEqual(966.644628099,b.value());
a = b;
// multiplication and division with double
a *= 1.21;
testNumbersEqual(1169.64,a.value());
b = a/2;
testNumbersEqual(584.82,b.value());
EXPECT_EQ("ft^2/s^4",b.standardUnitsString());
EXPECT_EQ("",b.prettyUnitsString());
Quantity c = 32.0/b;
EXPECT_EQ("s^4/ft^2",c.standardUnitsString());
testNumbersEqual(0.054717690913,c.value());
// Operations on Quantities with units of temperature
LOG(Debug,"Quantity_FahrenheitUnit_Arithmetic");
FahrenheitUnit fu1(1, 0, "");
Quantity T1(60.0,fu1);
FahrenheitUnit fu2(1);
Quantity T2(74.0,fu2);
Quantity TT1 = pow(T1,2);
Quantity TT2 = pow(T2,2);
EXPECT_TRUE(TT1.isAbsolute());
EXPECT_TRUE(TT2.isAbsolute());
Quantity q;
// -, unary
q = -T1;
testStreamOutput("-60 F",q);
q.setAsRelative();
q = -q;
testStreamOutput("60 F",q);
EXPECT_FALSE(q.isAbsolute());
// +, good units, bad units, absolute + relative = absolute
q = T1 + T2;
EXPECT_TRUE(q.isAbsolute());
testStreamOutput("134 F",q,0);
EXPECT_THROW(T1 + TT1,Exception);
q.setAsRelative();
q += T1;
EXPECT_TRUE(q.isAbsolute());
// -, binary, good units, bad units, absolute -> relative when exp == 1, ow same as +
q = T2 - T1;
testStreamOutput("14 F",q,0);
EXPECT_FALSE(q.isAbsolute());
//.........这里部分代码省略.........