本文整理汇总了C++中process::Future::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Future::get方法的具体用法?C++ Future::get怎么用?C++ Future::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类process::Future
的用法示例。
在下文中一共展示了Future::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AwaitAssertResponseBodyEq
inline ::testing::AssertionResult AwaitAssertResponseBodyEq(
const char* expectedExpr,
const char* actualExpr,
const char* durationExpr,
const std::string& expected,
const process::Future<process::http::Response>& actual,
const Duration& duration)
{
const ::testing::AssertionResult result =
AwaitAssertReady(actualExpr, durationExpr, actual, duration);
if (result) {
if (expected == actual.get().body) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure()
<< "Value of: (" << actualExpr << ").get().body\n"
<< " Actual: " << ::testing::PrintToString(actual.get().body) << "\n"
<< "Expected: " << expectedExpr << "\n"
<< "Which is: " << ::testing::PrintToString(expected);
}
}
return result;
}
示例2: AwaitAssertResponseHeaderEq
inline ::testing::AssertionResult AwaitAssertResponseHeaderEq(
const char* expectedExpr,
const char* keyExpr,
const char* actualExpr,
const char* durationExpr,
const std::string& expected,
const std::string& key,
const process::Future<process::http::Response>& actual,
const Duration& duration)
{
const ::testing::AssertionResult result =
AwaitAssertReady(actualExpr, durationExpr, actual, duration);
if (result) {
const Option<std::string> value = actual.get().headers.get(key);
if (value.isNone()) {
return ::testing::AssertionFailure()
<< "Response does not contain header '" << key << "'";
} else if (expected == value.get()) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure()
<< "Value of: (" << actualExpr << ").get().headers[" << keyExpr << "]\n"
<< " Actual: " << ::testing::PrintToString(value.get()) << "\n"
<< "Expected: " << expectedExpr << "\n"
<< "Which is: " << ::testing::PrintToString(expected);
}
}
return result;
}
示例3: AwaitAssertAbandoned
::testing::AssertionResult AwaitAssertAbandoned(
const char* expr,
const char*, // Unused string representation of 'duration'.
const process::Future<T>& actual,
const Duration& duration)
{
process::Owned<process::Latch> latch(new process::Latch());
actual.onAny([=]() { latch->trigger(); });
actual.onAbandoned([=]() { latch->trigger(); });
if (!latch->await(duration)) {
return ::testing::AssertionFailure()
<< "Failed to wait " << duration << " for " << expr;
} else if (actual.isDiscarded()) {
return ::testing::AssertionFailure()
<< expr << " was discarded";
} else if (actual.isReady()) {
return ::testing::AssertionFailure()
<< expr << " is ready (" << ::testing::PrintToString(actual.get()) << ")";
} else if (actual.isFailed()) {
return ::testing::AssertionFailure()
<< "(" << expr << ").failure(): " << actual.failure();
}
CHECK_ABANDONED(actual);
return ::testing::AssertionSuccess();
}
示例4: AssertTermSigNe
inline ::testing::AssertionResult AwaitAssertTermSigNe(
const char* expectedExpr,
const char* actualExpr,
const char* durationExpr,
const int expected,
const process::Future<Option<int>>& actual,
const Duration& duration)
{
const ::testing::AssertionResult result =
AwaitAssertSignaled(actualExpr, durationExpr, actual, duration);
if (result) {
CHECK_READY(actual);
CHECK_SOME(actual.get());
return AssertTermSigNe(
expectedExpr,
strings::join("(", actualExpr, ")->get()").c_str(),
expected,
actual->get());
}
return result;
}
示例5: AwaitAssertDiscarded
::testing::AssertionResult AwaitAssertDiscarded(
const char* expr,
const char*, // Unused string representation of 'duration'.
const process::Future<T>& actual,
const Duration& duration)
{
if (!process::internal::await(actual, duration)) {
return ::testing::AssertionFailure()
<< "Failed to wait " << duration << " for " << expr;
} else if (actual.isFailed()) {
return ::testing::AssertionFailure()
<< "(" << expr << ").failure(): " << actual.failure();
} else if (actual.isReady()) {
return ::testing::AssertionFailure()
<< expr << " is ready (" << ::testing::PrintToString(actual.get()) << ")";
}
return ::testing::AssertionSuccess();
}
示例6: AssertSignaled
inline ::testing::AssertionResult AwaitAssertSignaled(
const char* actualExpr,
const char* durationExpr,
const process::Future<Option<int>>& actual,
const Duration& duration)
{
const ::testing::AssertionResult result =
AwaitAssertReady(actualExpr, durationExpr, actual, duration);
if (result) {
CHECK_READY(actual);
if (actual->isNone()) {
return ::testing::AssertionFailure()
<< "(" << actualExpr << ")->isNone() is true";
}
return AssertSignaled(
strings::join("(", actualExpr, ")->get()").c_str(),
actual->get());
}
return result;
}