// ETH@20100521 Using this test to locate objects with characteristics I am looking for. Would
// rather use Ruby, but not quite sure about getting/using the installer.
TEST_F(IddFixture,IddFactory_ObjectFinder) {
    IddFileType fileType = IddFileType::WholeFactory;
    struct DesiredCharacteristics {
        bool operator()(const IddObject& object) {
            // fields that are \autocalculatable with no default, or a default other than 'autocalculate',
            // or fields that are \autosizable with no default or a default other than 'autosize'.
            for (const IddField& iddField : object.nonextensibleFields()) {
                if (iddField.properties().autocalculatable && (!iddField.properties().stringDefault ||
                        !istringEqual("autocalculate",iddField.properties().stringDefault.get())))
                {
                    return true;
                }
                if (iddField.properties().autosizable && (!iddField.properties().stringDefault ||
                        !istringEqual("autosize",iddField.properties().stringDefault.get())))
                {
                    return true;
                }
            }
            return false;
        }
    };

    IddFile iddFile = IddFactory::instance().getIddFile(fileType);
    IddObjectVector objects = iddFile.objects();
    LOG(Info,"IddObjects that satisfy DesiredCharacteristics:");
    DesiredCharacteristics tester;
    for (const IddObject& object : objects) {
        if (tester(object)) {
            LOG(Info,"  " << object.name());
        }
    }
}
TEST_F(IddFixture,IddFileAndFactoryWrapper_DirectlySetUserCustom) {
  IddFileAndFactoryWrapper wrapper(IddFileType::UserCustom);
  IddFile file = wrapper.iddFile();
  EXPECT_TRUE(file.objects().empty());
  BOOST_FOREACH(int typeIndex,IddObjectType::getValues()) {
    EXPECT_FALSE(wrapper.getObject(IddObjectType(typeIndex)));
  }
Esempio n. 3
0
// extensible object test, BuildingSurface:Detailed
void IddFile_BuildingSurfaceDetailed(const IddFile& iddFile)
{
  string objectName("BuildingSurface:Detailed");
  OptionalIddObject object = iddFile.getObject(objectName);
  ASSERT_TRUE(object);
  EXPECT_TRUE(iequals(object->name(), objectName));
  ASSERT_TRUE(object->nonextensibleFields().size() > 0);
  EXPECT_EQ(object->nonextensibleFields().size(), static_cast<unsigned int>(10));
  EXPECT_FALSE(object->properties().format.empty());
  EXPECT_TRUE(iequals("vertices", object->properties().format));

  EXPECT_TRUE(object->properties().extensible);
  EXPECT_TRUE(object->properties().numExtensible);
  ASSERT_EQ(static_cast<unsigned int>(3), object->properties().numExtensible);

  EXPECT_FALSE(object->getField("Vertex 1 X-coordinate"));
  EXPECT_FALSE(object->getField("Vertex 1 X-coordinate"));

  ASSERT_TRUE(object->extensibleGroup().size() > 0);
  string fieldName("Vertex X-coordinate");
  EXPECT_TRUE(iequals(fieldName, object->extensibleGroup().front().name() ));
  OptionalIddField field = object->getField(fieldName);
  ASSERT_TRUE(field);
  EXPECT_TRUE(iequals(fieldName, field->name()));
  EXPECT_TRUE(field->properties().beginExtensible);

  fieldName = "Vertex Z-coordinate";
  EXPECT_TRUE(iequals(fieldName, object->extensibleGroup().back().name() ));
  field = object->getField(fieldName);
  ASSERT_TRUE(field);
  EXPECT_TRUE(iequals(fieldName, field->name()));
  EXPECT_FALSE(field->properties().beginExtensible);
}
Esempio n. 4
0
// case insensitive test
void IddFile_bUiLdInG(const IddFile& iddFile)
{
  string objectName("bUiLdInG");
  OptionalIddObject object = iddFile.getObject(objectName);
  ASSERT_TRUE(object);
  EXPECT_TRUE(iequals(object->name(), objectName));
  EXPECT_EQ(static_cast<unsigned int>(8),object->nonextensibleFields().size());
  EXPECT_TRUE(object->properties().unique);
  EXPECT_TRUE(object->properties().required);

  string fieldName("TeRrAiN");
  OptionalIddField field = object->getField(fieldName);
  ASSERT_TRUE(field);
  EXPECT_TRUE(iequals(field->name(), fieldName));
  EXPECT_EQ(field->keys().size(), static_cast<unsigned int>(5) );
  EXPECT_TRUE(field->properties().stringDefault);
  EXPECT_EQ(*(field->properties().stringDefault), "Suburbs");
  EXPECT_FALSE(field->properties().numericDefault);

  string keyName("SuBuRbS");
  OptionalIddKey key = field->getKey(keyName);
  ASSERT_TRUE(key);
  EXPECT_FALSE(equals(key->name(), keyName));
  EXPECT_TRUE(iequals(key->name(), keyName));
}
Esempio n. 5
0
// test single object, no fields
void IddFile_LeadInput(const IddFile& iddFile)
{
  string objectName("Lead Input");
  OptionalIddObject object = iddFile.getObject(objectName);
  ASSERT_TRUE(object);
  EXPECT_EQ(object->name(), objectName);
  EXPECT_TRUE(object->nonextensibleFields().empty() );
}
void OSVersionFixture::SetUpTestCase() {
  // set up logging
  logFile = FileLogSink(toPath("./OSVersionFixture.log"));
  logFile->setLogLevel(Debug);
  Logger::instance().standardOutLogger().disable();

  // create and popluate resource folder
  openstudio::path thisVersionPath = versionResourcesPath(openstudio::VersionString(openStudioVersion()));
  if (!boost::filesystem::exists(thisVersionPath)) {
    boost::filesystem::create_directory(thisVersionPath);
  }

  // ETH@20120514 Eventually this cpp file should be configured by CMake so OpenStudio.idd can be 
  // directly copied over, and so all these items can be copied back into source.
  model::Model model = openstudio::model::exampleModel();
  model.save(thisVersionPath / toPath("example.osm"),true);
  model::Component component = model.getConcreteModelObjects<model::Construction>()[0].createComponent();
  component.save(thisVersionPath / toPath("example.osc"),true);
  IddFile iddFile = IddFactory::instance().getIddFile(IddFileType::OpenStudio);
  iddFile.save(thisVersionPath / toPath("OpenStudio.idd"),true);
}
Esempio n. 7
0
// test single object, one alpha field, no keys
void IddFile_Version(const IddFile& iddFile)
{
  string objectName("Version");
  OptionalIddObject object = iddFile.getObject(objectName);
  ASSERT_TRUE(object);
  EXPECT_EQ(object->name(), objectName);
  EXPECT_EQ(static_cast<unsigned int>(1),object->nonextensibleFields().size());

  string fieldName("Version Identifier");
  OptionalIddField field = object->getField(fieldName);
  ASSERT_TRUE(field);
  EXPECT_EQ(field->name(), fieldName);
  EXPECT_TRUE(field->keys().empty());
}
Esempio n. 8
0
IddFile IddFile::catchallIddFile() {
  IddFile result;
  result.addObject(IddObject());
  return result;
}
TEST_F(IddFixture,IddFactory_IddFile)
{
    IddFile file = IddFactory::instance().getIddFile(IddFileType::OpenStudio);
    EXPECT_TRUE(file.getObject("OS:Building"));
    EXPECT_TRUE(file.getObject(IddObjectType::CommentOnly));
    EXPECT_TRUE(file.getObject(IddObjectType::OS_ClimateZones));
    // print out for visual inspection
    path outPath = resourcesPath()/toPath("utilities/RoundTrip_OpenStudio.idd");
    file.save(outPath,true);
    // check against getIddObjects
    IddObjectVector objects = IddFactory::instance().getObjects(IddFileType::OpenStudio);
    EXPECT_TRUE(file.objects().size() == objects.size());
    // required objects
    EXPECT_TRUE(file.requiredObjects().size() > 0);
    EXPECT_TRUE(file.requiredObjects().size() ==
                IddFactory::instance().getRequiredObjects(IddFileType::OpenStudio).size());
    EXPECT_TRUE(file.requiredObjects().size() <= IddFactory::instance().requiredObjects().size());
    // unique objects
    EXPECT_TRUE(file.uniqueObjects().size() > 0);
    EXPECT_TRUE(file.uniqueObjects().size() ==
                IddFactory::instance().getUniqueObjects(IddFileType::OpenStudio).size());
    EXPECT_TRUE(file.uniqueObjects().size() <= IddFactory::instance().uniqueObjects().size());

    file = IddFactory::instance().getIddFile(IddFileType::EnergyPlus);
    EXPECT_TRUE(file.getObject("Building"));
    EXPECT_TRUE(file.getObject(IddObjectType::CommentOnly));
    EXPECT_FALSE(file.getObject(IddObjectType::OS_ClimateZones));
    // print out for visual inspection
    outPath = resourcesPath()/toPath("energyplus/RoundTrip_ProposedEnergy+.idd");
    file.save(outPath,true);
    // check against getIddObjects
    objects = IddFactory::instance().getObjects(IddFileType::EnergyPlus);
    EXPECT_TRUE(file.objects().size() == objects.size());
}