From fbf771c340f6f29a9fdabbbcce82058039d1dff4 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Fri, 1 Oct 2021 11:56:06 +0200 Subject: [PATCH] Add a unit test for all ForwardTranslator Options (Failing for two) --- .../Test/ForwardTranslator_GTest.cpp | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/src/energyplus/Test/ForwardTranslator_GTest.cpp b/src/energyplus/Test/ForwardTranslator_GTest.cpp index 8bb3d7cc7b0..6ce5f8bb573 100644 --- a/src/energyplus/Test/ForwardTranslator_GTest.cpp +++ b/src/energyplus/Test/ForwardTranslator_GTest.cpp @@ -758,3 +758,124 @@ TEST_F(EnergyPlusFixture, BadVariableName) { EXPECT_TRUE(s == "Good Name" || s == "Bad, !Name") << s; } } + +TEST_F(EnergyPlusFixture, ForwardTranslation_Options) { + + Model m; + ForwardTranslator ft; + + // Defaults + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(5u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); + + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); + ASSERT_EQ(1, objs.size()); + auto obj = objs[0]; + EXPECT_EQ("HTML", obj.getString(0).get()); + EXPECT_EQ("None", obj.getString(1, true).get()); // Return default + EXPECT_FALSE(obj.getString(1, false, true)); // not initialized + } + + ft.setExcludeLCCObjects(true); + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); + + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); + ASSERT_EQ(1, objs.size()); + auto obj = objs[0]; + EXPECT_EQ("HTML", obj.getString(0).get()); + EXPECT_EQ("None", obj.getString(1, true).get()); // Return default + EXPECT_FALSE(obj.getString(1, false, true)); // not initialized + } + + ft.setExcludeVariableDictionary(true); + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); + ASSERT_EQ(1, objs.size()); + auto obj = objs[0]; + EXPECT_EQ("HTML", obj.getString(0).get()); + EXPECT_EQ("None", obj.getString(1, true).get()); // Return default + EXPECT_FALSE(obj.getString(1, false, true)); // not initialized + } + + ft.setExcludeSQliteOutputReport(true); + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); + ASSERT_EQ(1, objs.size()); + auto obj = objs[0]; + EXPECT_EQ("HTML", obj.getString(0).get()); + EXPECT_EQ("None", obj.getString(1, true).get()); // Return default + EXPECT_FALSE(obj.getString(1, false, true)); // not initialized + } + + ft.setIPTabularOutput(true); + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_NonrecurringCost)); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(1u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + auto objs = w.getObjectsByType(IddObjectType::OutputControl_Table_Style); + ASSERT_EQ(1, objs.size()); + auto obj = objs[0]; + EXPECT_EQ("HTML", obj.getString(0).get()); + EXPECT_EQ("InchPound", obj.getString(1, false, true).get()); + } + + ft.setExcludeHTMLOutputReport(true); + { + Workspace w = ft.translateModel(m); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_Parameters)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_UsePriceEscalation)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::LifeCycleCost_RecurringCosts)); + + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_VariableDictionary)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_SQLite)); + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::Output_Table_SummaryReports)); + + // This also turns off the OutputControl:Table:Style + EXPECT_EQ(0u, w.numObjectsOfType(IddObjectType::OutputControl_Table_Style)); + } +}