本文整理汇总了C++中testing::Invoke方法的典型用法代码示例。如果您正苦于以下问题:C++ testing::Invoke方法的具体用法?C++ testing::Invoke怎么用?C++ testing::Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing
的用法示例。
在下文中一共展示了testing::Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spawn
TEST(HTTP, Get)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
HttpProcess process;
spawn(process);
EXPECT_CALL(process, get(_))
.WillOnce(Invoke(validateGetWithoutQuery));
Future<http::Response> noQueryFuture = http::get(process.self(), "get");
AWAIT_READY(noQueryFuture);
ASSERT_EQ(http::statuses[200], noQueryFuture.get().status);
EXPECT_CALL(process, get(_))
.WillOnce(Invoke(validateGetWithQuery));
Future<http::Response> queryFuture =
http::get(process.self(), "get", "foo=bar");
AWAIT_READY(queryFuture);
ASSERT_EQ(http::statuses[200], queryFuture.get().status);
terminate(process);
wait(process);
}
示例2: frame
TEST_F(TeleCommandHandlingTest, HandlerShouldBeCalledForKnownTelecommand)
{
std::uint8_t buffer[40] = "ABCD";
CommFrame frame(0, 0, 0, buffer);
EXPECT_CALL(this->deps, Decrypt(_, _)).WillOnce(Invoke([](span<const uint8_t> frame, span<uint8_t> decrypted) {
auto lastCopied = std::copy(frame.cbegin(), frame.cend(), decrypted.begin());
auto decryptedDataLength = lastCopied - decrypted.begin();
return DecryptFrameResult::Success(decrypted.subspan(0, decryptedDataLength));
}));
EXPECT_CALL(this->deps, Decode(_)).WillOnce(Invoke([](span<const uint8_t> frame) {
return DecodeTelecommandResult::Success(frame[0], frame.subspan(1, frame.length() - 1));
}));
NiceMock<TeleCommandHandlerMock> someCommand;
EXPECT_CALL(someCommand, Handle(_, _));
EXPECT_CALL(someCommand, CommandCode()).WillRepeatedly(Return(static_cast<uint8_t>('A')));
IHandleTeleCommand* commands[] = {&someCommand};
IncomingTelecommandHandler handler(deps, deps, span<IHandleTeleCommand*>(commands));
handler.HandleFrame(this->transmitFrame, frame);
}
示例3: runTask
MockSlave::MockSlave(const slave::Flags& flags,
MasterDetector* detector,
slave::Containerizer* containerizer,
const Option<mesos::slave::QoSController*>& _qosController)
: slave::Slave(
flags,
detector,
containerizer,
&files,
&gc,
statusUpdateManager = new slave::StatusUpdateManager(flags),
&resourceEstimator,
_qosController.isSome() ? _qosController.get() : &qosController)
{
// Set up default behaviors, calling the original methods.
EXPECT_CALL(*this, runTask(_, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask));
EXPECT_CALL(*this, _runTask(_, _, _, _))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked__runTask));
EXPECT_CALL(*this, killTask(_, _, _))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_killTask));
EXPECT_CALL(*this, removeFramework(_))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked_removeFramework));
EXPECT_CALL(*this, __recover(_))
.WillRepeatedly(Invoke(this, &MockSlave::unmocked___recover));
}
示例4: run
MockFetcherProcess::MockFetcherProcess()
{
// Set up default behaviors, calling the original methods.
EXPECT_CALL(*this, _fetch(_, _, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockFetcherProcess::unmocked__fetch));
EXPECT_CALL(*this, run(_, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockFetcherProcess::unmocked_run));
}
示例5: fetch
MockDockerContainerizerProcess::MockDockerContainerizerProcess(
const slave::Flags& flags,
slave::Fetcher* fetcher,
const process::Shared<Docker>& docker)
: slave::DockerContainerizerProcess(flags, fetcher, docker)
{
EXPECT_CALL(*this, fetch(_, _))
.WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_fetch));
EXPECT_CALL(*this, pull(_))
.WillRepeatedly(Invoke(this, &MockDockerContainerizerProcess::_pull));
}
示例6: spawn
TEST(HTTP, Post)
{
ASSERT_TRUE(GTEST_IS_THREADSAFE);
HttpProcess process;
spawn(process);
// Test the case where there is a content type but no body.
Future<http::Response> future =
http::post(process.self(), "post", None(), "text/plain");
AWAIT_EXPECT_FAILED(future);
EXPECT_CALL(process, post(_))
.WillOnce(Invoke(validatePost));
future =
http::post(process.self(), "post", "This is the payload.", "text/plain");
AWAIT_READY(future);
ASSERT_EQ(http::statuses[200], future.get().status);
terminate(process);
wait(process);
}
示例7: TestStore
TestStore(const hashmap<std::string, process::Shared<Rootfs>>& _rootfses)
: rootfses(_rootfses)
{
using testing::_;
using testing::DoDefault;
using testing::Invoke;
ON_CALL(*this, recover())
.WillByDefault(Invoke(this, &TestStore::unmocked_recover));
EXPECT_CALL(*this, recover())
.WillRepeatedly(DoDefault());
ON_CALL(*this, get(_))
.WillByDefault(Invoke(this, &TestStore::unmocked_get));
EXPECT_CALL(*this, get(_))
.WillRepeatedly(DoDefault());
}
示例8: Docker
MockDocker::MockDocker(
const std::string& path,
const std::string &socket)
: Docker(path, socket)
{
EXPECT_CALL(*this, pull(_, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_pull));
EXPECT_CALL(*this, stop(_, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_stop));
EXPECT_CALL(*this, run(_, _, _, _, _, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_run));
EXPECT_CALL(*this, inspect(_, _))
.WillRepeatedly(Invoke(this, &MockDocker::_inspect));
}
示例9: Docker
MockDocker::MockDocker(
const string& path,
const string& socket,
const Option<JSON::Object>& config)
: Docker(path, socket, config)
{
EXPECT_CALL(*this, ps(_, _))
.WillRepeatedly(Invoke(this, &MockDocker::_ps));
EXPECT_CALL(*this, pull(_, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_pull));
EXPECT_CALL(*this, stop(_, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_stop));
EXPECT_CALL(*this, run(_, _, _, _, _, _, _, _, _, _))
.WillRepeatedly(Invoke(this, &MockDocker::_run));
EXPECT_CALL(*this, inspect(_, _))
.WillRepeatedly(Invoke(this, &MockDocker::_inspect));
}
示例10: get
TEST(HTTP, Get)
{
Http http;
EXPECT_CALL(*http.process, get(_))
.WillOnce(Invoke(validateGetWithoutQuery));
Future<http::Response> noQueryFuture = http::get(http.process->self(), "get");
AWAIT_READY(noQueryFuture);
ASSERT_EQ(http::statuses[200], noQueryFuture.get().status);
EXPECT_CALL(*http.process, get(_))
.WillOnce(Invoke(validateGetWithQuery));
Future<http::Response> queryFuture =
http::get(http.process->self(), "get", "foo=bar");
AWAIT_READY(queryFuture);
ASSERT_EQ(http::statuses[200], queryFuture.get().status);
}
示例11: runTask
MockSlave::MockSlave(const slave::Flags& flags,
MasterDetector* detector,
slave::Containerizer* containerizer)
: slave::Slave(
flags,
detector,
containerizer,
&files,
&gc,
statusUpdateManager = new slave::StatusUpdateManager(flags))
{
// Set up default behaviors, calling the original methods.
EXPECT_CALL(*this, runTask(_, _, _, _, _)).
WillRepeatedly(Invoke(this, &MockSlave::unmocked_runTask));
EXPECT_CALL(*this, _runTask(_, _, _, _, _)).
WillRepeatedly(Invoke(this, &MockSlave::unmocked__runTask));
EXPECT_CALL(*this, killTask(_, _, _)).
WillRepeatedly(Invoke(this, &MockSlave::unmocked_killTask));
EXPECT_CALL(*this, removeFramework(_)).
WillRepeatedly(Invoke(this, &MockSlave::unmocked_removeFramework));
}
示例12: WriteRead
TEST_F(AntennaMiniportTest, TestAntennaActivationTime)
{
EXPECT_CALL(i2c, WriteRead(ANTENNA_PRIMARY_CHANNEL, ElementsAre(QueryActivationTime1), _))
.WillOnce(Invoke([=](uint8_t /*address*/, span<const uint8_t> /*inData*/, span<uint8_t> outData) {
std::fill(outData.begin(), outData.end(), 0);
outData[0] = 10;
return I2CResult::OK;
}));
TimeSpan response;
const auto status = miniport.GetAntennaActivationTime(&miniport, &i2c, ANTENNA_PRIMARY_CHANNEL, ANTENNA1_ID, &response);
ASSERT_THAT(status, Eq(OSResult::Success));
ASSERT_THAT(response, Eq(TimeSpanFromMilliseconds(128000)));
}
示例13: TestProvisioner
TestProvisioner(const process::Shared<Rootfs>& _rootfs)
: rootfs(_rootfs)
{
using testing::_;
using testing::DoDefault;
using testing::Invoke;
ON_CALL(*this, recover(_, _))
.WillByDefault(Invoke(this, &TestProvisioner::unmocked_recover));
EXPECT_CALL(*this, recover(_, _))
.WillRepeatedly(DoDefault());
ON_CALL(*this, provision(_, _))
.WillByDefault(Invoke(this, &TestProvisioner::unmocked_provision));
EXPECT_CALL(*this, provision(_, _))
.WillRepeatedly(DoDefault());
ON_CALL(*this, destroy(_))
.WillByDefault(Invoke(this, &TestProvisioner::unmocked_destroy));
EXPECT_CALL(*this, destroy(_))
.WillRepeatedly(DoDefault());
}
示例14: requestDelete
TEST(HTTPTest, Delete)
{
Http http;
EXPECT_CALL(*http.process, requestDelete(_))
.WillOnce(Invoke(validateDelete));
Future<http::Response> future =
http::requestDelete(http.process->self(), "delete", None());
AWAIT_READY(future);
ASSERT_EQ(http::statuses[200], future.get().status);
}
示例15: None
TEST(HTTPTest, Post)
{
Http http;
// Test the case where there is a content type but no body.
Future<http::Response> future =
http::post(http.process->self(), "post", None(), None(), "text/plain");
AWAIT_EXPECT_FAILED(future);
EXPECT_CALL(*http.process, post(_))
.WillOnce(Invoke(validatePost));
future = http::post(
http.process->self(),
"post",
None(),
"This is the payload.",
"text/plain");
AWAIT_READY(future);
ASSERT_EQ(http::Status::OK, future->code);
ASSERT_EQ(http::Status::string(http::Status::OK), future->status);
// Now test passing headers instead.
http::Headers headers;
headers["Content-Type"] = "text/plain";
EXPECT_CALL(*http.process, post(_))
.WillOnce(Invoke(validatePost));
future =
http::post(http.process->self(), "post", headers, "This is the payload.");
AWAIT_READY(future);
ASSERT_EQ(http::Status::OK, future->code);
ASSERT_EQ(http::Status::string(http::Status::OK), future->status);
}