TEST(MockComparatorCopierTest, twoInterleavedCustomTypeOutputParameters) { MyTypeForTesting expectedObject1(9545); MyTypeForTesting actualObject1(79); MyTypeForTesting expectedObject2(132); MyTypeForTesting actualObject2(743); MyTypeForTestingCopier copier; mock().installCopier("MyTypeForTesting", copier); mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject1).withParameter("id", 1); mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject2).withParameter("id", 2); mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject2).withParameter("id", 2); mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject1).withParameter("id", 1); mock().checkExpectations(); CHECK_EQUAL(9545, *(expectedObject1.value)); CHECK_EQUAL(9545, *(actualObject1.value)); CHECK_EQUAL(132, *(expectedObject2.value)); CHECK_EQUAL(132, *(actualObject2.value)); mock().removeAllComparatorsAndCopiers(); }
TEST(MockComparatorCopierTest, twoCustomTypeOutputParametersOfSameNameInDifferentFunctionsSucceeds) { MyTypeForTesting expectedObject1(657); MyTypeForTesting actualObject1(984465); MyTypeForTesting expectedObject2(987); MyTypeForTesting actualObject2(987); MyTypeForTestingCopier copier; MyTypeForTestingComparator comparator; mock().installCopier("MyTypeForTesting", copier); mock().installComparator("MyTypeForTesting", comparator); mock().expectOneCall("foo1").withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject1); mock().expectOneCall("foo2").withParameterOfType("MyTypeForTesting", "bar", &expectedObject2); mock().actualCall("foo1").withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject1); mock().actualCall("foo2").withParameterOfType("MyTypeForTesting", "bar", &actualObject2); mock().checkExpectations(); CHECK_EQUAL(657, *(expectedObject1.value)); CHECK_EQUAL(657, *(actualObject1.value)); CHECK_EQUAL(987, *(expectedObject2.value)); CHECK_EQUAL(987, *(actualObject2.value)); mock().removeAllComparatorsAndCopiers(); }
TEST(MockComparatorCopierTest, twoDifferentCustomTypeOutputParametersInSameFunctionCallSucceeds) { MyTypeForTesting expectedObject1(11); MyTypeForTesting actualObject1(22); MyTypeForTesting expectedObject2(33); MyTypeForTesting actualObject2(44); MyTypeForTestingCopier copier; mock().installCopier("MyTypeForTesting", copier); mock().expectOneCall("foo") .withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject1) .withOutputParameterOfTypeReturning("MyTypeForTesting", "foobar", &expectedObject2); mock().actualCall("foo") .withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject1) .withOutputParameterOfType("MyTypeForTesting", "foobar", &actualObject2); mock().checkExpectations(); CHECK_EQUAL(11, *(expectedObject1.value)); CHECK_EQUAL(11, *(actualObject1.value)); CHECK_EQUAL(33, *(expectedObject2.value)); CHECK_EQUAL(33, *(actualObject2.value)); mock().removeAllComparatorsAndCopiers(); }