| 57 | }; |
| 58 | |
| 59 | TEST_F(RubyEngineFixture, BadMeasure) { |
| 60 | ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
| 61 | |
| 62 | ASSERT_DEATH( |
| 63 | { |
| 64 | const std::string classAndDirName = "BadMeasure"; |
| 65 | |
| 66 | const auto scriptPath = getScriptPath(classAndDirName); |
| 67 | auto measureScriptObject = (*thisEngine)->loadMeasure(scriptPath, classAndDirName); |
| 68 | auto* measurePtr = (*thisEngine)->getAs<openstudio::measure::ModelMeasure*>(measureScriptObject); |
| 69 | |
| 70 | ASSERT_EQ(measurePtr->name(), "Bad Measure"); |
| 71 | |
| 72 | std::string expected_exception = fmt::format(R"(SWIG director method error. RuntimeError: oops |
| 73 | |
| 74 | Traceback (most recent call last): |
| 75 | {0}:12:in `another_method' |
| 76 | {0}:16:in `arguments')", |
| 77 | scriptPath.generic_string()); |
| 78 | |
| 79 | openstudio::model::Model model; |
| 80 | |
| 81 | try { |
| 82 | measurePtr->arguments(model); |
| 83 | ASSERT_FALSE(true) << "Expected measure arguments(model) to throw"; |
| 84 | } catch (std::exception& e) { |
| 85 | std::string error = e.what(); |
| 86 | EXPECT_EQ(expected_exception, error); |
| 87 | } |
| 88 | |
| 89 | thisEngine->reset(); |
| 90 | }, |
| 91 | "oops"); |
| 92 | } |
| 93 | |
| 94 | TEST_F(RubyEngineFixture, WrongMethodMeasure) { |
| 95 | ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
nothing calls this directly
no test coverage detected