TEST_F(IddFixture,IddFactory_OpenStudioUnits_SubTest1) { IddObjectVector objects = IddFactory::instance().getObjects(IddFileType(IddFileType::OpenStudio)); bool found = false; for (const IddObject& object : objects) { IddFieldVector fields = object.nonextensibleFields(); IddFieldVector temp = object.extensibleGroup(); fields.insert(fields.end(),temp.begin(),temp.end()); for (const IddField& field : fields) { if (OptionalString iddUnits = field.properties().ipUnits) { if (*iddUnits == "Btu/h-ft-F") { found = true; OptionalUnit siUnit = field.getUnits(false); ASSERT_TRUE(siUnit); EXPECT_TRUE(siUnit->system() == UnitSystem::SI); EXPECT_EQ("kg*m/s^3*K",siUnit->standardString(false)); OptionalUnit ipUnit = field.getUnits(true); ASSERT_TRUE(ipUnit); EXPECT_TRUE(ipUnit->system() == UnitSystem::BTU); Quantity q(1.0,*ipUnit); OptionalQuantity testQ = convert(q,*siUnit); EXPECT_TRUE(testQ); break; } } } if (found) { break; } } EXPECT_TRUE(found); }
TEST_F(UnitsFixture,IddUnits_BtuSystem) { IddUnitString iddString("Btu/h-ft-F"); EXPECT_EQ("Btu/h*ft*R",iddString.toStandardUnitString()); OptionalUnit unit = createUnit(iddString.toStandardUnitString()); ASSERT_TRUE(unit); EXPECT_TRUE(unit->system() == UnitSystem::BTU); }
TEST_F(IddFixture,IddFactory_OpenStudioUnits_SubTest3) { IddObjectVector objects = IddFactory::instance().getObjects(IddFileType(IddFileType::OpenStudio)); bool found = false; for (const IddObject& object : objects) { IddFieldVector fields = object.nonextensibleFields(); IddFieldVector temp = object.extensibleGroup(); fields.insert(fields.end(),temp.begin(),temp.end()); for (const IddField& field : fields) { if (OptionalString iddUnits = field.properties().ipUnits) { if (*iddUnits == "gal/min") { if (object.type() == IddObjectType::OS_AirTerminal_SingleDuct_ParallelPIU_Reheat) { LOG(Debug,"Gal/min field: " << field.name()); } found = true; OptionalUnit ipUnit = field.getUnits(true); ASSERT_TRUE(ipUnit); EXPECT_TRUE(ipUnit->system() == UnitSystem::Mixed); EXPECT_EQ("crgal^3/min",ipUnit->standardString()); EXPECT_EQ("gal/min",ipUnit->prettyString()); } } } } EXPECT_TRUE(found); }
TEST_F(IddFixture,IddFactory_OpenStudioUnits_SubTest2) { IddObjectVector objects = IddFactory::instance().getObjects(IddFileType(IddFileType::OpenStudio)); bool found = false; for (const IddObject& object : objects) { IddFieldVector fields = object.nonextensibleFields(); IddFieldVector temp = object.extensibleGroup(); fields.insert(fields.end(),temp.begin(),temp.end()); for (const IddField& field : fields) { if (OptionalString iddUnits = field.properties().units) { if (*iddUnits == "kg-H2O/kg-Air") { found = true; OptionalUnit siUnit = field.getUnits(); ASSERT_TRUE(siUnit); EXPECT_TRUE(siUnit->system() == UnitSystem::SI); EXPECT_EQ("",siUnit->standardString()); EXPECT_EQ("kg_{H2O}/kg_{air}",siUnit->prettyString()); break; } } } if (found) { break; } } EXPECT_TRUE(found); }
TEST_F(UnitsFixture,IddUnits_Grams) { IddUnitString iddString("g/m-s-K"); EXPECT_EQ("mkg/m*s*K",iddString.toStandardUnitString()); OptionalUnit unit = createUnit(iddString.toStandardUnitString()); ASSERT_TRUE(unit); EXPECT_TRUE(unit->system() == UnitSystem::SI); EXPECT_EQ(-3,unit->scale().exponent); }