本文整理汇总了C++中Autowired::GetContext方法的典型用法代码示例。如果您正苦于以下问题:C++ Autowired::GetContext方法的具体用法?C++ Autowired::GetContext怎么用?C++ Autowired::GetContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autowired
的用法示例。
在下文中一共展示了Autowired::GetContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTestEnd
void AutowiringEnclosure::OnTestEnd(const testing::TestInfo& info) {
// Verify we can grab the test case back out and that the pointer is correct:
Autowired<TestInfoProxy> ti;
Autowired<AutowiringEnclosureExceptionFilter> ecef;
auto ctxt = ecef ? ecef->GetContext() : nullptr;
// Unconditionally reset the global context as the current context
AutoGlobalContext()->SetCurrent();
// Global initialization tests are special, we don't bother checking closure principle on them:
if(!strcmp("GlobalInitTest", info.test_case_name()))
return;
// Need to make sure we got back our exception filter before continuing:
ASSERT_TRUE(ecef.IsAutowired()) << "Failed to find the enclosed context exception filter; unit test may have incorrectly reset the enclosing context before returning";
// Now try to tear down the test context enclosure:
ctxt->SignalShutdown();
// Do not allow teardown to take more than 250 milliseconds or so
if(!ctxt->Wait(std::chrono::milliseconds(250))) {
// Critical error--took too long to tear down
assert(false);
}
static const char s_autothrow[] = "AUTOTHROW_";
if(!strncmp(s_autothrow, info.name(), ARRAYCOUNT(s_autothrow) - 1))
// Throw expected, end here
return;
// If an exception occurred somewhere, report it:
ASSERT_FALSE(ecef->m_excepted)
<< "An unhandled exception occurred in this context" << std::endl
<< "[" << (ecef->m_ti ? ecef->m_ti->name() : "unknown") << "] " << ecef->m_what;
}