本文整理汇总了C++中MockRepository类的典型用法代码示例。如果您正苦于以下问题:C++ MockRepository类的具体用法?C++ MockRepository怎么用?C++ MockRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockRepository类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vmxon
void
vmxon_ut::test_stop_vmxoff_check_failure()
{
MockRepository mocks;
auto in = bfn::mock_shared<intrinsics_intel_x64>(mocks);
auto intrinsics = in.get();
auto l_mm = bfn::mock_shared<memory_manager>(mocks);
mm = l_mm.get();
// execute_vmxoff
mocks.OnCall(intrinsics, intrinsics_intel_x64::vmxoff).Return(true);
// disable_vmx_operation
Call &cr4_0 = mocks.ExpectCall(intrinsics, intrinsics_intel_x64::read_cr4).Return(0);
mocks.OnCall(intrinsics, intrinsics_intel_x64::write_cr4).Do(stubbed_write_cr4);
// is_vmx_operation_enabled
mocks.ExpectCall(intrinsics, intrinsics_intel_x64::read_cr4).After(cr4_0).Return(CR4_VMXE_VMX_ENABLE_BIT);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
vmxon_intel_x64 vmxon(in);
EXPECT_EXCEPTION(vmxon.stop(), bfn::vmxon_failure_error);
});
}
示例2: TEST
TEST(TestTinyMock,TestIfFailureNotifierIsCalledOnlyWithTheFirstFailingExpectation)
{
const int argValue = 25 ;
MockRepository<YaffutFailureNotifier> mockRepository;
TestMock* testMock = mockRepository.CreateMock<TestMock, ExceptionFailureNotifier>("TestMock");
testMock->RegisterExpectation(new TinyMock::Method<int,void,void,void,void>("TestMethodWithAnArgument",argValue));
testMock->RegisterExpectation(new TinyMock::Method<int,void,void,void,void>("TestMethodWithAnArgument",argValue));
try
{
testMock->TestMethodWithAnArgument(argValue-1);
}
catch(exception)
{
try
{
testMock->TestMethodWithAnArgument(argValue-1);
}
catch(exception)
{
FAIL("PIES");
}
mockRepository.verifyAll();
return;
}
FAIL("");
}
示例3: TEST
TEST(DiscoveryManagerTest, CallbackWouldNotBeCalledForSameRemoteResource) {
FindCallback callback;
MockRepository mocks;
mocks.OnCallFuncOverload(static_cast<OCFindResource>(findResource)).Do(
[&callback](const std::string&, const std::string&, OCConnectivityType, FindCallback cb)
{
callback = cb;
return OC_STACK_OK;
}
).Return(OC_STACK_OK);
ScopedTask aTask {RCSDiscoveryManager::getInstance()->discoverResource(RCSAddress::multicast(),
onResourceDiscovered)};
std::vector< std::string > interfaces{ "interface" };
std::vector< std::string > resourceTypes{ "resource.type" };
constexpr char fakeHost[] { "coap://127.0.0.1:1" };
mocks.ExpectCallFunc(onResourceDiscovered);
callback(OCPlatform::constructResourceObject(fakeHost, "/uri", OCConnectivityType::CT_ADAPTER_IP,
true, interfaces, resourceTypes));
mocks.NeverCallFunc(onResourceDiscovered);
callback(OCPlatform::constructResourceObject(fakeHost, "/uri", OCConnectivityType::CT_ADAPTER_IP,
true, interfaces, resourceTypes));
}
示例4: EXPECT_TRUE
void
driver_entry_ut::test_common_dump_resolve_symbol_failed()
{
EXPECT_TRUE(common_add_module(m_dummy1, m_dummy1_length) == BF_SUCCESS);
EXPECT_TRUE(common_add_module(m_dummy2, m_dummy2_length) == BF_SUCCESS);
EXPECT_TRUE(common_add_module(m_dummy3, m_dummy3_length) == BF_SUCCESS);
EXPECT_TRUE(common_load_vmm() == BF_SUCCESS);
// We need to wrap the mocks variable in a temporary stack frame as the
// current implementation of HippoMocks does not have a function to undo
// it's hooks into c-style functions as the functionality to do this is
// in the destructor.
{
MockRepository mocks;
mocks.OnCallFunc(resolve_symbol).Return(-1);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
EXPECT_TRUE(common_dump_vmm() == BF_ERROR_FAILED_TO_DUMP_DR);
});
}
EXPECT_TRUE(common_unload_vmm() == BF_SUCCESS);
}
示例5: GTEST_TEST
GTEST_TEST(ConstructResourceObjectTest, ConstructResourceObjectInValidReturnValue)
{
MockRepository mocks;
OCResource::Ptr rightdoor = std::shared_ptr<OCResource>();
mocks.ExpectCallFunc(OCPlatform::constructResourceObject).Return(NULL);
std::vector<std::string> types = {"core.rightdoor"};
OCResource::Ptr leftdoor = OCPlatform::constructResourceObject("192.168.1.2:5000",
"a/rightdoor", false, types, ifaces);
bool value = (leftdoor == NULL);
EXPECT_EQ(true, value);
}
示例6: GTEST_TEST
//using mocks framework
GTEST_TEST(ConstructResourceObjectTest, ConstructResourceObjectValidReturnValue)
{
MockRepository mocks;
OCResource::Ptr rightdoor = std::shared_ptr<OCResource>();
OCConnectivityType connectivityType = OC_WIFI;
mocks.ExpectCallFunc(OCPlatform::constructResourceObject).Return(rightdoor);
std::vector<std::string> types = {"core.leftdoor"};
OCResource::Ptr leftdoor = OCPlatform::constructResourceObject("192.168.1.2:5000",
"a/leftdoor", connectivityType, false, types, ifaces);
EXPECT_EQ(leftdoor, rightdoor);
}
示例7:
void
driver_entry_ut::test_common_load_loader_init_failed()
{
MockRepository mocks;
mocks.OnCallFunc(bfelf_loader_init).Return(-1);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
EXPECT_TRUE(common_load_vmm() == -1);
});
}
示例8:
void
driver_entry_ut::test_common_dump_status_unloaded()
{
MockRepository mocks;
mocks.OnCallFunc(vmm_status).Return(VMM_UNLOADED);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
EXPECT_TRUE(common_dump_vmm() == BF_ERROR_VMM_INVALID_STATE);
});
}
示例9: TEST
TEST(SyncEngine, loadAllSources0)
{
MockRepository mocks;
CDBAdapter* db = mocks.ClassMock<CDBAdapter>();
mocks.ExpectCall(db, CDBAdapter::prepareStatement).Return(new CDBResult(g_mxDB));
CSyncEngine oSyncEngine(*db);
oSyncEngine.loadAllSources();
EXPECT_EQ(0, oSyncEngine.getSources().size());
}
示例10:
void
memory_manager_ut::test_root_page_table_x64_map_add_md_failure()
{
MockRepository mocks;
auto &&mm = setup_mm(mocks);
mocks.OnCall(mm, memory_manager_x64::add_md).Throw(std::runtime_error("error"));
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
this->expect_exception([&] { g_pt->map(0x12347000, 0x54323000, x64::memory_attr::rw_wb); }, ""_ut_ree);
});
}
示例11:
void
entry_ut::test_start_vmm_success()
{
MockRepository mocks;
auto vcm = mocks.Mock<vcpu_manager>();
mocks.OnCallFunc(vcpu_manager::instance).Return(vcm);
mocks.OnCall(vcm, vcpu_manager::init);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
EXPECT_NO_EXCEPTION(start_vmm(0));
});
}
示例12: vmm
void
vmm_ut::test_verify_vmx_capabilities_msr_failed_invalid_memory_type()
{
MockRepository mocks;
intrinsics_intel_x64 *intrinsics = mocks.Mock<intrinsics_intel_x64>();
vmm_intel_x64 vmm(intrinsics);
mocks.OnCall(intrinsics, intrinsics_intel_x64::read_msr).With(IA32_VMX_BASIC_MSR).Return(0);
RUN_UNITTEST_WITH_MOCKS(mocks, [&]
{
EXPECT_TRUE(vmm.verify_vmx_capabilities_msr() == vmm_error::not_supported);
});
}
示例13: TearDown
virtual void TearDown()
{
try
{
mocks.VerifyAll();
}
catch (...)
{
mocks.reset();
throw;
}
}