本文整理汇总了C++中MockExpectedCallsListForTest::addFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ MockExpectedCallsListForTest::addFunction方法的具体用法?C++ MockExpectedCallsListForTest::addFunction怎么用?C++ MockExpectedCallsListForTest::addFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockExpectedCallsListForTest
的用法示例。
在下文中一共展示了MockExpectedCallsListForTest::addFunction方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expectedFailure
TEST(MockCallTest, OnObjectFails)
{
MockFailureReporterInstaller failureReporterInstaller;
void* objectPtr = (void*) 0x001;
void* objectPtr2 = (void*) 0x002;
MockExpectedCallsListForTest expectations;
expectations.addFunction("boo")->onObject(objectPtr);
mock().expectOneCall("boo").onObject(objectPtr);
mock().actualCall("boo").onObject(objectPtr2);
MockUnexpectedObjectFailure expectedFailure(mockFailureTest(), "boo", objectPtr2, expectations);
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例2: mock
TEST(MockParameterTest, outputParameterMissing)
{
MockFailureReporterInstaller failureReporterInstaller;
int output;
MockExpectedCallsListForTest expectations;
mock().expectOneCall("foo").withOutputParameterReturning("output", &output, sizeof(output));
mock().actualCall("foo");
expectations.addFunction("foo")->withOutputParameterReturning("output", &output, sizeof(output));
MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例3: parameter
TEST(MockParameterTest, expectOneIntegerParameterAndFailsDueToTypes)
{
MockFailureReporterInstaller failureReporterInstaller;
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withParameter("parameter", 10);
MockNamedValue parameter("parameter");
parameter.setValue("heh");
MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations);
mock().expectOneCall("foo").withParameter("parameter", 10);
mock().actualCall("foo").withParameter("parameter", "heh");
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例4: expectedFailure
TEST(MockCallTest, ignoreOtherCallsDoesntIgnoreMultipleCallsOfTheSameFunction)
{
MockFailureReporterInstaller failureReporterInstaller;
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->callWasMade(1);
MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "foo", expectations);
mock().expectOneCall("foo");
mock().ignoreOtherCalls();
mock().actualCall("bar");
mock().actualCall("foo");
mock().actualCall("foo");
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例5: object
TEST(MockComparatorCopierTest, customObjectWithFunctionComparatorThatFailsCoversValueToString)
{
MockFailureReporterInstaller failureReporterInstaller;
MyTypeForTesting object(5);
MockFunctionComparator comparator(myTypeIsEqual, myTypeValueToString);
mock().installComparator("MyTypeForTesting", comparator);
MockExpectedCallsListForTest expectations;
expectations.addFunction("function")->withParameterOfType("MyTypeForTesting", "parameterName", &object);
MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), expectations);
mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE_LOCATION(failure, __FILE__, __LINE__);
}
示例6: expectedObject
TEST(MockComparatorCopierTest, noCopierForCustomTypeOutputParameter)
{
MockFailureReporterInstaller failureReporterInstaller;
MyTypeForTesting expectedObject(123464);
MyTypeForTesting actualObject(8834);
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
MockNoWayToCopyCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting");
mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "output", &actualObject);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例7: expectedFailure
TEST(MockStrictOrderTest, orderViolatedWithinAScope)
{
MockFailureReporterInstaller failureReporterInstaller;
mock().strictOrder();
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo1", 1)->callWasMade(2);
expectations.addFunction("foo2", 2)->callWasMade(1);
MockCallOrderFailure expectedFailure(mockFailureTest(), expectations);
mock("scope").expectOneCall("foo1");
mock("scope").expectOneCall("foo2");
mock("scope").actualCall("foo2");
mock("scope").actualCall("foo1");
mock("scope").checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例8: mock
TEST(MockCallTest, OnObjectExpectedButNotCalled)
{
MockFailureReporterInstaller failureReporterInstaller;
void* objectPtr = (void*) 0x001;
MockExpectedCallsListForTest expectations;
expectations.addFunction("boo")->onObject(objectPtr);
expectations.addFunction("boo")->onObject(objectPtr);
mock().expectOneCall("boo").onObject(objectPtr);
mock().expectOneCall("boo").onObject(objectPtr);
mock().actualCall("boo");
mock().actualCall("boo");
MockExpectedObjectDidntHappenFailure expectedFailure(mockFailureTest(), "boo", expectations);
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
示例9: actualObject
TEST(MockComparatorCopierTest, unexpectedCustomTypeOutputParameter)
{
MockFailureReporterInstaller failureReporterInstaller;
MyTypeForTesting actualObject(8834);
MyTypeForTestingCopier copier;
mock().installCopier("MyTypeForTesting", copier);
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo");
MockNamedValue parameter("parameterName");
parameter.setConstObjectPointer("MyTypeForTesting", &actualObject);
MockUnexpectedOutputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations);
mock().expectOneCall("foo");
mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
mock().removeAllComparatorsAndCopiers();
}
示例10: expectedObject
TEST(MockComparatorCopierTest, customTypeOutputParameterOfWrongType)
{
MockFailureReporterInstaller failureReporterInstaller;
MyTypeForTesting expectedObject(123464);
MyTypeForTesting actualObject(75646);
MyTypeForTestingCopier copier;
mock().installCopier("MyTypeForTesting", copier);
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
MockNamedValue parameter("output");
parameter.setObjectPointer("OtherTypeForTesting", &actualObject);
MockUnexpectedOutputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations);
mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
mock().actualCall("foo").withOutputParameterOfType("OtherTypeForTesting", "output", &actualObject);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
mock().removeAllComparatorsAndCopiers();
}