TEST_F(UnitsFixture,Scale_LogicalOperators) { LOG(Debug,"Scale_LogicalOperators"); // == and != ASSERT_TRUE(one() == one()); ASSERT_FALSE(one() == notDefined()); ASSERT_TRUE(kilo() != micro()); // <, <=, >, >= ASSERT_TRUE(centi() < one()); ASSERT_TRUE(mega() > kilo()); ASSERT_TRUE(one() <= giga()); ASSERT_TRUE(milli() >= micro()); }
TEST_F(UnitsFixture,Scale_DefinedConstants) { LOG(Debug,"Scale_DefinedConstants"); // tests << via the log macro LOG(Info,notDefined()); LOG(Info,yotta()); LOG(Info,zetta()); LOG(Info,exa()); LOG(Info,peta()); LOG(Info,tera()); LOG(Info,giga()); LOG(Info,mega()); LOG(Info,kilo()); LOG(Info,one()); LOG(Info,centi()); LOG(Info,milli()); LOG(Info,micro()); LOG(Info,nano()); LOG(Info,pico()); LOG(Info,femto()); LOG(Info,atto()); LOG(Info,zepto()); LOG(Info,yocto()); }
// Tests arithmetic operations, which relies on the factory method for creating // scales from exponents. TEST_F(UnitsFixture,ScaleFactory_ScaleOperations) { LOG(Debug,"ScaleFactory_ScaleOperations"); // MULTIPLICATION // exact match in factory ScaleOpReturnType scaleResult = kilo()*milli(); ASSERT_EQ(scaleResult.first().exponent,0); testNumbersEqual(1.0,scaleResult.second); // exact match not in factory scaleResult = centi()*kilo(); ASSERT_EQ(scaleResult.first().exponent,0); testNumbersEqual(10.0,scaleResult.second); // DIVISION // exact match in factory scaleResult = giga()/mega(); ASSERT_EQ(scaleResult.first().exponent,3); testNumbersEqual(1.0,scaleResult.second); // exact match not in factory scaleResult = micro()/centi(); ASSERT_EQ(scaleResult.first().exponent,-3); testNumbersEqual(0.1,scaleResult.second); // POWER // exact match in factory scaleResult = pow(kilo(),3); ASSERT_EQ(scaleResult.first().exponent,9); testNumbersEqual(1.0,scaleResult.second); scaleResult = pow(one(),12); ASSERT_EQ(scaleResult.first().exponent,0); testNumbersEqual(1.0,scaleResult.second); // exact match not in factory scaleResult = pow(centi(),-2); ASSERT_EQ(3,scaleResult.first().exponent); testNumbersEqual(10.0,scaleResult.second); }