Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers umock_c_prod.h Source File

umock_c_prod.h

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 #undef MOCKABLE_FUNCTION
00005 
00006 /* This header is meant to be included by production code headers, so that the MOCKABLE_FUNCTION gets enabled. */
00007 /* 
00008     If you are porting to a new platform and do not want to build the tests, but only the production code,
00009     simply make sure that this file is in the include path (either by copying it to your inc folder or 
00010     by adjusting the include paths).
00011 */
00012 
00013 #ifdef ENABLE_MOCKS
00014 
00015 /* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/
00016 #define MOCKABLE_FUNCTION(modifiers, result, function, ...) \
00017     MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK(modifiers, result, function, __VA_ARGS__)
00018 
00019 #include "umock_c.h"
00020 
00021 #else
00022 
00023 #include "azure_c_shared_utility/macro_utils.h"
00024 
00025 #define UMOCK_C_PROD_ARG_IN_SIGNATURE(count, arg_type, arg_name) arg_type arg_name IFCOMMA(count)
00026 
00027 /* Codes_SRS_UMOCK_C_LIB_01_002: [The macro shall generate a function signature in case ENABLE_MOCKS is not defined.] */
00028 /* Codes_SRS_UMOCK_C_LIB_01_005: [**If ENABLE_MOCKS is not defined, MOCKABLE_FUNCTION shall only generate a declaration for the function.] */
00029 /* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/
00030 #define MOCKABLE_FUNCTION(modifiers, result, function, ...) \
00031     result modifiers function(IF(COUNT_ARG(__VA_ARGS__),,void) FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__));
00032 
00033 #endif