TEST(MockSupport_c, whenNoReturnValueIsGivenReturnIntValueOrDefaultShouldlUseTheDefaultValue) { int defaultValue = -10; mock_c()->expectOneCall("foo"); LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnIntValueOrDefault(defaultValue)); LONGS_EQUAL(defaultValue, mock_c()->returnIntValueOrDefault(defaultValue)); }
TEST(MockSupport_c, returnIntValue) { int expected_value = 10; mock_c()->expectOneCall("boo")->andReturnIntValue(expected_value); LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->returnValue().value.intValue); LONGS_EQUAL(MOCKVALUETYPE_INTEGER, mock_c()->returnValue().type); }
TEST(MockSupport_c, expectAndActualParameters) { mock_c()->expectOneCall("boo")->withIntParameters("integer", 1)->withDoubleParameters("double", 1.0)-> withStringParameters("string", "string")->withPointerParameters("pointer", (void*) 1); mock_c()->actualCall("boo")->withIntParameters("integer", 1)->withDoubleParameters("double", 1.0)-> withStringParameters("string", "string")->withPointerParameters("pointer", (void*) 1); }
celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement) { mock_c()->actualCall("requirement_create") ->withPointerParameters("directives", directives) ->withPointerParameters("attributes", attributes) ->withOutputParameter("requirement", (void **) requirement); return mock_c()->returnValue().value.intValue; }
celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange) { mock_c()->actualCall("versionRange_isInRange") ->withPointerParameters("versionRange", versionRange) ->withPointerParameters("version", version) ->withOutputParameter("inRange", (int *) inRange); return mock_c()->returnValue().value.intValue; }
celix_status_t serviceRegistry_unregisterService(service_registry_pt registry, bundle_pt bundle, service_registration_pt registration) { mock_c()->actualCall("serviceRegistry_unregisterService") ->withPointerParameters("registry", registry) ->withPointerParameters("bundle", bundle) ->withPointerParameters("registration", registration); return mock_c()->returnValue().value.intValue; }
celix_status_t serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal) { mock_c()->actualCall("serviceReference_equals") ->withPointerParameters("reference", reference) ->withPointerParameters("compareTo", compareTo) ->withOutputParameter("equal", equal); return mock_c()->returnValue().value.intValue; }
TEST(MockSupport_c, returnConstPointerValue) { mock_c()->expectOneCall("boo")->andReturnConstPointerValue((const void*) 10); POINTERS_EQUAL((const void*) 10, mock_c()->actualCall("boo")->constPointerReturnValue()); POINTERS_EQUAL((const void*) 10, mock_c()->constPointerReturnValue()); LONGS_EQUAL(MOCKVALUETYPE_CONST_POINTER, mock_c()->returnValue().type); }
TEST(MockSupport_c, whenNoReturnValueIsGivenReturnConstPointerValueOrDefaultShouldlUseTheDefaultValue) { const void* defaultValue = (void*) 10; mock_c()->expectOneCall("foo"); POINTERS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnConstPointerValueOrDefault(defaultValue)); POINTERS_EQUAL(defaultValue, mock_c()->returnConstPointerValueOrDefault(defaultValue)); }
TEST(MockSupport_c, returnDoubleValue) { mock_c()->expectOneCall("boo")->andReturnDoubleValue(1.0); DOUBLES_EQUAL(1.0, mock_c()->actualCall("boo")->doubleReturnValue(), 0.005); DOUBLES_EQUAL(1.0, mock_c()->doubleReturnValue(), 0.005); LONGS_EQUAL(MOCKVALUETYPE_DOUBLE, mock_c()->returnValue().type); }
TEST(MockSupport_c, whenNoReturnValueIsGivenReturnDoubleValueOrDefaultShouldlUseTheDefaultValue) { double defaultValue = 2.2; mock_c()->expectOneCall("foo"); DOUBLES_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnDoubleValueOrDefault(defaultValue), 0.005); DOUBLES_EQUAL(defaultValue, mock_c()->returnDoubleValueOrDefault(defaultValue), 0.005); }
TEST(MockSupport_c, whenNoReturnValueIsGivenReturnStringValueOrDefaultShouldlUseTheDefaultValue) { const char defaultValue[] = "bar"; mock_c()->expectOneCall("foo"); STRCMP_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnStringValueOrDefault(defaultValue)); STRCMP_EQUAL(defaultValue, mock_c()->returnStringValueOrDefault(defaultValue)); }
TEST(MockSupport_c, returnStringValue) { mock_c()->expectOneCall("boo")->andReturnStringValue("hello world"); STRCMP_EQUAL("hello world", mock_c()->actualCall("boo")->stringReturnValue()); STRCMP_EQUAL("hello world", mock_c()->stringReturnValue()); LONGS_EQUAL(MOCKVALUETYPE_STRING, mock_c()->returnValue().type); }
TEST(MockSupport_c, whenNoReturnValueIsGivenReturnUnsignedLongIntValueOrDefaultShouldlUseTheDefaultValue) { unsigned long int defaultValue = 10L; mock_c()->expectOneCall("foo"); LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnUnsignedLongIntValueOrDefault(defaultValue)); LONGS_EQUAL(defaultValue, mock_c()->returnUnsignedLongIntValueOrDefault(defaultValue)); }
celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_function_pt serviceChanged, service_registry_pt *registry) { mock_c()->actualCall("serviceRegistry_create") ->withPointerParameters("framework", framework) ->withPointerParameters("serviceChanged", serviceChanged) ->withOutputParameter("registry", registry); return mock_c()->returnValue().value.intValue; }
TEST(MockSupport_c, returnFunctionPointerValue) { mock_c()->expectOneCall("boo")->andReturnFunctionPointerValue(dummy_function_for_mock_c_test); FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->actualCall("boo")->functionPointerReturnValue()); FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->functionPointerReturnValue()); LONGS_EQUAL(MOCKVALUETYPE_FUNCTIONPOINTER, mock_c()->returnValue().type); }
celix_status_t serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, array_list_pt *services) { mock_c()->actualCall("serviceRegistry_getServicesInUse") ->withPointerParameters("registry", registry) ->withPointerParameters("bundle", bundle) ->withOutputParameter("services", services); return mock_c()->returnValue().value.intValue; }
TEST(MockSupport_c, expectNoCall) { mock_c()->expectNoCall("foo"); mock_c()->expectOneCall("bar"); mock_c()->actualCall("bar"); mock_c()->checkExpectations(); }
celix_status_t serviceReference_create(bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference) { mock_c()->actualCall("serviceReference_create") ->withPointerParameters("bundle", bundle) ->withPointerParameters("registration", registration) ->withOutputParameter("reference", (void **) reference); return mock_c()->returnValue().value.intValue; }
celix_status_t bundleArchive_revise(bundle_archive_pt archive, char * location, char *inputFile) { mock_c()->actualCall("bundleArchive_revise") ->withPointerParameters("archive", archive) ->withStringParameters("location", location) ->withStringParameters("inputFile", inputFile); return mock_c()->returnValue().value.intValue; }
celix_status_t frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, char *msg) { mock_c()->actualCall("frameworkLogger_log"); test_logger_print(level, func, file, line, msg); return mock_c()->returnValue().value.intValue; }
celix_status_t bundleArchive_getRevision(bundle_archive_pt archive, long revNr, bundle_revision_pt *revision) { mock_c()->actualCall("bundleArchive_getRevision") ->withPointerParameters("archive", archive) ->withLongIntParameters("revNr", revNr) ->withOutputParameter("revision", revision); return mock_c()->returnValue().value.intValue; }
celix_status_t requirement_isSatisfied(requirement_pt requirement, capability_pt capability, bool *inRange) { mock_c()->actualCall("requirement_isSatisfied") ->withPointerParameters("requirement", requirement) ->withPointerParameters("capability", capability) ->withOutputParameter("inRange", inRange); return mock_c()->returnValue().value.intValue; }
celix_status_t serviceRegistry_ungetService(service_registry_pt registry, bundle_pt bundle, service_reference_pt reference, bool *result) { mock_c()->actualCall("serviceRegistry_ungetService") ->withPointerParameters("registry", registry) ->withPointerParameters("bundle", bundle) ->withOutputParameter("result", result); return mock_c()->returnValue().value.intValue; }
module_pt module_create(manifest_pt headerMap, char * moduleId, bundle_pt bundle) { mock_c()->actualCall("module_create") ->withPointerParameters("headerMap", headerMap) ->withStringParameters("moduleId", moduleId) ->withPointerParameters("bundle", bundle); return mock_c()->returnValue().value.pointerValue; }
celix_status_t serviceRegistry_getListenerHooks(service_registry_pt registry, bundle_pt bundle, array_list_pt *hooks) { mock_c()->actualCall("serviceRegistry_getListenerHooks") ->withPointerParameters("registry", registry) ->withPointerParameters("bundle", bundle) ->withOutputParameter("hooks", hooks); return mock_c()->returnValue().value.intValue; }
TEST(MockSupport_c, returnUnsignedLongIntValue) { unsigned long int expected_value = 10; mock_c()->expectOneCall("boo")->andReturnUnsignedLongIntValue(expected_value); LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->returnValue().value.unsignedLongIntValue); LONGS_EQUAL(MOCKVALUETYPE_UNSIGNED_LONG_INTEGER, mock_c()->returnValue().type); }
celix_status_t serviceRegistry_servicePropertiesModified(service_registry_pt registry, service_registration_pt registration, properties_pt oldprops) { mock_c()->actualCall("serviceRegistry_servicePropertiesModified") ->withPointerParameters("registry", registry) ->withPointerParameters("registration", registration) ->withPointerParameters("oldprops", oldprops); return mock_c()->returnValue().value.intValue; }
TEST(MockSupport_c, memoryBufferParameter) { const unsigned char mem_buffer[] = { 1, 2, 3}; mock_c()->expectOneCall("foo")->withMemoryBufferParameter("out", mem_buffer, sizeof(mem_buffer)); mock_c()->actualCall("foo")->withMemoryBufferParameter("out", mem_buffer, sizeof(mem_buffer)); mock_c()->checkExpectations(); }
TEST(MockSupport_c, expectAndActualParametersOnObject) { mock_c()->installComparator("typeName", typeNameIsEqual, typeNameValueToString); mock_c()->expectOneCall("boo")->withParameterOfType("typeName", "name", (const void*) 1); mock_c()->actualCall("boo")->withParameterOfType("typeName", "name", (const void*) 1); mock_c()->checkExpectations(); mock_c()->removeAllComparators(); }