TEST_F(EnergyPlusFixture,ForwardTranslator_Surface) { Model model; Point3dVector points; points.push_back(Point3d(0, 1, 0)); points.push_back(Point3d(0, 0, 0)); points.push_back(Point3d(1, 0, 0)); points.push_back(Point3d(1, 1, 0)); Surface surface(points, model); ForwardTranslator forwardTranslator; Workspace workspace = forwardTranslator.translateModel(model); EXPECT_EQ(0u, forwardTranslator.errors().size()); EXPECT_EQ(0u, forwardTranslator.warnings().size()); ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::BuildingSurface_Detailed).size()); }
TEST_F(EnergyPlusFixture, ForwardTranslatorTest_MultiThreadedLogMessages) { // This thread calls forward translator, this is not a good example of threading // just used for testing class ForwardTranslatorThread : public QThread { public: ForwardTranslator translator; Model model; boost::optional<Workspace> workspace; ForwardTranslatorThread(Model _model) : model(_model) {} protected: void run(){ workspace = translator.translateModel(model); } }; Logger::instance().standardOutLogger().enable(); Model model; Space space(model); // not in thermal zone will generate a warning // run in current thread unsigned numWarnings = 0; { ForwardTranslator translator; boost::optional<Workspace> workspace = translator.translateModel(model); ASSERT_TRUE(workspace); numWarnings = translator.warnings().size(); EXPECT_NE(0, numWarnings); } // run single thread { ForwardTranslatorThread thread(model); EXPECT_FALSE(thread.workspace); thread.start(); thread.wait(); ASSERT_TRUE(thread.workspace); numWarnings = thread.translator.warnings().size(); EXPECT_EQ(numWarnings, thread.translator.warnings().size()); } // run four threads { ForwardTranslatorThread thread1(model); ForwardTranslatorThread thread2(model); ForwardTranslatorThread thread3(model); ForwardTranslatorThread thread4(model); EXPECT_FALSE(thread1.workspace); EXPECT_FALSE(thread2.workspace); EXPECT_FALSE(thread3.workspace); EXPECT_FALSE(thread4.workspace); thread1.start(); thread2.start(); thread3.start(); thread4.start(); thread1.wait(); thread2.wait(); thread3.wait(); thread4.wait(); ASSERT_TRUE(thread1.workspace); ASSERT_TRUE(thread2.workspace); ASSERT_TRUE(thread3.workspace); ASSERT_TRUE(thread4.workspace); EXPECT_EQ(numWarnings, thread1.translator.warnings().size()); EXPECT_EQ(numWarnings, thread2.translator.warnings().size()); EXPECT_EQ(numWarnings, thread3.translator.warnings().size()); EXPECT_EQ(numWarnings, thread4.translator.warnings().size()); } }