void test_MemNextWillReturnNullIfGivenABadRoot(void) { TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(0) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(2) ); TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, CMock_Guts_MemNext(CMOCK_MEM_SIZE - 4) ); //verify we're cleared still TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); }
void test_MemNextWillReturnNullIfGivenABadRoot(void) { TEST_ASSERT_NULL( CMock_Guts_MemNext(NULL) ); TEST_ASSERT_NULL( CMock_Guts_MemNext((void*)2) ); TEST_ASSERT_NULL( CMock_Guts_MemNext((void*)0xFFFFFFFE) ); //verify we're cleared still TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesFree()); }
void listAdd(List* list, int data) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_listAdd_CALL_INSTANCE* cmock_call_instance = (CMOCK_listAdd_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.listAdd_CallInstance); Mock.listAdd_CallInstance = CMock_Guts_MemNext(Mock.listAdd_CallInstance); if (Mock.listAdd_IgnoreBool) { return; } if (Mock.listAdd_CallbackFunctionPointer != NULL) { Mock.listAdd_CallbackFunctionPointer(list, data, Mock.listAdd_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'listAdd' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'listAdd' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'listAdd' called later than expected."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_list), (void*)(list), sizeof(List), cmock_line, "Function 'listAdd' called with unexpected value for argument 'list'."); UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_data, data, cmock_line, "Function 'listAdd' called with unexpected value for argument 'data'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } }
void* system_init(void* base_address, uint32_t type_size) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; UNITY_SET_DETAIL(CMockString_system_init); CMOCK_system_init_CALL_INSTANCE* cmock_call_instance = (CMOCK_system_init_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.system_init_CallInstance); Mock.system_init_CallInstance = CMock_Guts_MemNext(Mock.system_init_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore); cmock_line = cmock_call_instance->LineNumber; { UNITY_SET_DETAILS(CMockString_system_init,CMockString_base_address); if (cmock_call_instance->Expected_base_address == NULL) { UNITY_TEST_ASSERT_NULL(base_address, cmock_line, CMockStringExpNULL); } else { // Autogenerated mock tests equality of data. // We are using specific HW addresses, just test addresses. UNITY_TEST_ASSERT_EQUAL_HEX32( cmock_call_instance->Expected_base_address, base_address, cmock_line, CMockStringMismatch); } } { UNITY_SET_DETAILS(CMockString_system_init,CMockString_type_size); UNITY_TEST_ASSERT_EQUAL_HEX32(cmock_call_instance->Expected_type_size, type_size, cmock_line, CMockStringMismatch); } UNITY_CLR_DETAILS(); return cmock_call_instance->ReturnVal; }
void stringRightTrim(String* string) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_stringRightTrim_CALL_INSTANCE* cmock_call_instance = (CMOCK_stringRightTrim_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.stringRightTrim_CallInstance); Mock.stringRightTrim_CallInstance = CMock_Guts_MemNext(Mock.stringRightTrim_CallInstance); if (Mock.stringRightTrim_IgnoreBool) { return; } if (Mock.stringRightTrim_CallbackFunctionPointer != NULL) { Mock.stringRightTrim_CallbackFunctionPointer(string, Mock.stringRightTrim_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'stringRightTrim' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringRightTrim' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringRightTrim' called later than expected."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_string), (void*)(string), sizeof(String), cmock_line, "Function 'stringRightTrim' called with unexpected value for argument 'string'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } }
void stringCopy(char* source, char* destination, int startLocation, int length) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_stringCopy_CALL_INSTANCE* cmock_call_instance = (CMOCK_stringCopy_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.stringCopy_CallInstance); Mock.stringCopy_CallInstance = CMock_Guts_MemNext(Mock.stringCopy_CallInstance); if (Mock.stringCopy_IgnoreBool) { return; } if (Mock.stringCopy_CallbackFunctionPointer != NULL) { Mock.stringCopy_CallbackFunctionPointer(source, destination, startLocation, length, Mock.stringCopy_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'stringCopy' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringCopy' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringCopy' called later than expected."); UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_source, source, cmock_line, "Function 'stringCopy' called with unexpected value for argument 'source'."); UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_destination, destination, cmock_line, "Function 'stringCopy' called with unexpected value for argument 'destination'."); UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_startLocation, startLocation, cmock_line, "Function 'stringCopy' called with unexpected value for argument 'startLocation'."); UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_length, length, cmock_line, "Function 'stringCopy' called with unexpected value for argument 'length'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } }
Stack* Stack_create(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_Stack_create_CALL_INSTANCE* cmock_call_instance = (CMOCK_Stack_create_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.Stack_create_CallInstance); Mock.Stack_create_CallInstance = CMock_Guts_MemNext(Mock.Stack_create_CallInstance); if (Mock.Stack_create_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.Stack_create_FinalReturn; Mock.Stack_create_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.Stack_create_CallbackFunctionPointer != NULL) { return Mock.Stack_create_CallbackFunctionPointer(Mock.Stack_create_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'Stack_create' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'Stack_create' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'Stack_create' called later than expected."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } return cmock_call_instance->ReturnVal; }
qeo_retcode_t qeo_security_policy_get_fine_grained_rules(qeo_security_policy_hndl qeoSecPol, uintptr_t cookie, const char* topic_name, unsigned int selector_mask, qeo_security_policy_update_fine_grained_rules_cb update_cb) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeo_security_policy_get_fine_grained_rules_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_security_policy_get_fine_grained_rules_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeo_security_policy_get_fine_grained_rules_CallInstance); Mock.qeo_security_policy_get_fine_grained_rules_CallInstance = CMock_Guts_MemNext(Mock.qeo_security_policy_get_fine_grained_rules_CallInstance); if (Mock.qeo_security_policy_get_fine_grained_rules_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.qeo_security_policy_get_fine_grained_rules_FinalReturn; memcpy(&Mock.qeo_security_policy_get_fine_grained_rules_FinalReturn, &cmock_call_instance->ReturnVal, sizeof(qeo_retcode_t)); return cmock_call_instance->ReturnVal; } if (Mock.qeo_security_policy_get_fine_grained_rules_CallbackFunctionPointer != NULL) { return Mock.qeo_security_policy_get_fine_grained_rules_CallbackFunctionPointer(qeoSecPol, cookie, topic_name, selector_mask, update_cb, Mock.qeo_security_policy_get_fine_grained_rules_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_qeoSecPol), (void*)(&qeoSecPol), sizeof(qeo_security_policy_hndl), cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'qeoSecPol'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_cookie), (void*)(&cookie), sizeof(uintptr_t), cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'cookie'."); if (cmock_call_instance->Expected_topic_name == NULL) { UNITY_TEST_ASSERT_NULL(topic_name, cmock_line, "Expected NULL. Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'topic_name'."); } else { UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(cmock_call_instance->Expected_topic_name, topic_name, 1, cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'topic_name'."); } UNITY_TEST_ASSERT_EQUAL_HEX32(cmock_call_instance->Expected_selector_mask, selector_mask, cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'selector_mask'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_update_cb), (void*)(&update_cb), sizeof(qeo_security_policy_update_fine_grained_rules_cb), cmock_line, "Function 'qeo_security_policy_get_fine_grained_rules' called with unexpected value for argument 'update_cb'."); return cmock_call_instance->ReturnVal; }
String* stringCreate(char* expression) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_stringCreate_CALL_INSTANCE* cmock_call_instance = (CMOCK_stringCreate_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.stringCreate_CallInstance); Mock.stringCreate_CallInstance = CMock_Guts_MemNext(Mock.stringCreate_CallInstance); if (Mock.stringCreate_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.stringCreate_FinalReturn; Mock.stringCreate_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.stringCreate_CallbackFunctionPointer != NULL) { return Mock.stringCreate_CallbackFunctionPointer(expression, Mock.stringCreate_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'stringCreate' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringCreate' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'stringCreate' called later than expected."); UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_expression, expression, cmock_line, "Function 'stringCreate' called with unexpected value for argument 'expression'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } return cmock_call_instance->ReturnVal; }
String* getWordAndUpdate(String* line, char* delimiter) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_getWordAndUpdate_CALL_INSTANCE* cmock_call_instance = (CMOCK_getWordAndUpdate_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.getWordAndUpdate_CallInstance); Mock.getWordAndUpdate_CallInstance = CMock_Guts_MemNext(Mock.getWordAndUpdate_CallInstance); if (Mock.getWordAndUpdate_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.getWordAndUpdate_FinalReturn; Mock.getWordAndUpdate_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.getWordAndUpdate_CallbackFunctionPointer != NULL) { return Mock.getWordAndUpdate_CallbackFunctionPointer(line, delimiter, Mock.getWordAndUpdate_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'getWordAndUpdate' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'getWordAndUpdate' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'getWordAndUpdate' called later than expected."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_line), (void*)(line), sizeof(String), cmock_line, "Function 'getWordAndUpdate' called with unexpected value for argument 'line'."); UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_delimiter, delimiter, cmock_line, "Function 'getWordAndUpdate' called with unexpected value for argument 'delimiter'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } return cmock_call_instance->ReturnVal; }
List* ListNew(int length) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_ListNew_CALL_INSTANCE* cmock_call_instance = (CMOCK_ListNew_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.ListNew_CallInstance); Mock.ListNew_CallInstance = CMock_Guts_MemNext(Mock.ListNew_CallInstance); if (Mock.ListNew_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.ListNew_FinalReturn; Mock.ListNew_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.ListNew_CallbackFunctionPointer != NULL) { return Mock.ListNew_CallbackFunctionPointer(length, Mock.ListNew_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'ListNew' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'ListNew' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'ListNew' called later than expected."); UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_length, length, cmock_line, "Function 'ListNew' called with unexpected value for argument 'length'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } return cmock_call_instance->ReturnVal; }
Token* calculate(Operator* opeToken, Number* first, Number* second) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_calculate_CALL_INSTANCE* cmock_call_instance = (CMOCK_calculate_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.calculate_CallInstance); Mock.calculate_CallInstance = CMock_Guts_MemNext(Mock.calculate_CallInstance); if (Mock.calculate_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.calculate_FinalReturn; Mock.calculate_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.calculate_CallbackFunctionPointer != NULL) { return Mock.calculate_CallbackFunctionPointer(opeToken, first, second, Mock.calculate_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'calculate' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'calculate' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'calculate' called later than expected."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_opeToken), (void*)(opeToken), sizeof(Operator), cmock_line, "Function 'calculate' called with unexpected value for argument 'opeToken'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_first), (void*)(first), sizeof(Number), cmock_line, "Function 'calculate' called with unexpected value for argument 'first'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_second), (void*)(second), sizeof(Number), cmock_line, "Function 'calculate' called with unexpected value for argument 'second'."); return cmock_call_instance->ReturnVal; }
qeo_util_retcode_t qeo_platform_get_device_storage_path(const char* file_name, char** full_storage_path) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeo_platform_get_device_storage_path_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_platform_get_device_storage_path_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeo_platform_get_device_storage_path_CallInstance); Mock.qeo_platform_get_device_storage_path_CallInstance = CMock_Guts_MemNext(Mock.qeo_platform_get_device_storage_path_CallInstance); if (Mock.qeo_platform_get_device_storage_path_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.qeo_platform_get_device_storage_path_FinalReturn; memcpy(&Mock.qeo_platform_get_device_storage_path_FinalReturn, &cmock_call_instance->ReturnVal, sizeof(qeo_util_retcode_t)); return cmock_call_instance->ReturnVal; } if (Mock.qeo_platform_get_device_storage_path_CallbackFunctionPointer != NULL) { return Mock.qeo_platform_get_device_storage_path_CallbackFunctionPointer(file_name, full_storage_path, Mock.qeo_platform_get_device_storage_path_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeo_platform_get_device_storage_path' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_file_name, file_name, cmock_line, "Function 'qeo_platform_get_device_storage_path' called with unexpected value for argument 'file_name'."); if (cmock_call_instance->Expected_full_storage_path == NULL) { UNITY_TEST_ASSERT_NULL(full_storage_path, cmock_line, "Expected NULL. Function 'qeo_platform_get_device_storage_path' called with unexpected value for argument 'full_storage_path'."); } else { UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(cmock_call_instance->Expected_full_storage_path, full_storage_path, 1, cmock_line, "Function 'qeo_platform_get_device_storage_path' called with unexpected value for argument 'full_storage_path'."); } return cmock_call_instance->ReturnVal; }
qeo_util_retcode_t qeo_platform_get_key_value(const char* key, char** value) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeo_platform_get_key_value_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_platform_get_key_value_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeo_platform_get_key_value_CallInstance); Mock.qeo_platform_get_key_value_CallInstance = CMock_Guts_MemNext(Mock.qeo_platform_get_key_value_CallInstance); if (Mock.qeo_platform_get_key_value_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.qeo_platform_get_key_value_FinalReturn; memcpy(&Mock.qeo_platform_get_key_value_FinalReturn, &cmock_call_instance->ReturnVal, sizeof(qeo_util_retcode_t)); return cmock_call_instance->ReturnVal; } if (Mock.qeo_platform_get_key_value_CallbackFunctionPointer != NULL) { return Mock.qeo_platform_get_key_value_CallbackFunctionPointer(key, value, Mock.qeo_platform_get_key_value_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeo_platform_get_key_value' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_key, key, cmock_line, "Function 'qeo_platform_get_key_value' called with unexpected value for argument 'key'."); if (cmock_call_instance->Expected_value == NULL) { UNITY_TEST_ASSERT_NULL(value, cmock_line, "Expected NULL. Function 'qeo_platform_get_key_value' called with unexpected value for argument 'value'."); } else { UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(cmock_call_instance->Expected_value, value, 1, cmock_line, "Function 'qeo_platform_get_key_value' called with unexpected value for argument 'value'."); } return cmock_call_instance->ReturnVal; }
int isNumber(Token* unknownToken) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_isNumber_CALL_INSTANCE* cmock_call_instance = (CMOCK_isNumber_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.isNumber_CallInstance); Mock.isNumber_CallInstance = CMock_Guts_MemNext(Mock.isNumber_CallInstance); if (Mock.isNumber_IgnoreBool) { if (cmock_call_instance == NULL) return Mock.isNumber_FinalReturn; Mock.isNumber_FinalReturn = cmock_call_instance->ReturnVal; return cmock_call_instance->ReturnVal; } if (Mock.isNumber_CallbackFunctionPointer != NULL) { return Mock.isNumber_CallbackFunctionPointer(unknownToken, Mock.isNumber_CallbackCalls++); } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'isNumber' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'isNumber' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'isNumber' called later than expected."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_unknownToken), (void*)(unknownToken), sizeof(Token), cmock_line, "Function 'isNumber' called with unexpected value for argument 'unknownToken'."); if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE) { Throw(cmock_call_instance->ExceptionToThrow); } return cmock_call_instance->ReturnVal; }
void test_ThatWeCanAskForAllSortsOfSizes(void) { unsigned int i; CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE; CMOCK_MEM_INDEX_TYPE next; unsigned int sizes[10] = {3, 1, 80, 5, 8, 31, 7, 911, 2, 80}; unsigned int sizes_buffered[10] = {16, 16, 88, 16, 16, 40, 16, 920, 16, 88}; //includes counter unsigned int sum = 0; unsigned int cap; for (i = 0; i < 10; i++) { next = CMock_Guts_MemNew(sizes[i]); TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); first = CMock_Guts_MemChain(first, next); TEST_ASSERT_MESSAGE(first != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); sum += sizes_buffered[i]; cap = (StartingSize > (sum + CMOCK_MEM_SIZE)) ? StartingSize : (sum + CMOCK_MEM_SIZE); TEST_ASSERT_EQUAL(sum, CMock_Guts_MemBytesUsed()); TEST_ASSERT(cap >= CMock_Guts_MemBytesFree()); } //verify we can still walk through the elements allocated next = first; for (i = 0; i < 10; i++) { TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); next = CMock_Guts_MemNext(next); } //there aren't any after that TEST_ASSERT_EQUAL_HEX( CMOCK_GUTS_NONE, next); }
void TimerConductor_Run(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_TimerConductor_Run_CALL_INSTANCE* cmock_call_instance = (CMOCK_TimerConductor_Run_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.TimerConductor_Run_CallInstance); Mock.TimerConductor_Run_CallInstance = CMock_Guts_MemNext(Mock.TimerConductor_Run_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'TimerConductor_Run' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; }
void Adc_StartTemperatureSensorConversion(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_Adc_StartTemperatureSensorConversion_CALL_INSTANCE* cmock_call_instance = (CMOCK_Adc_StartTemperatureSensorConversion_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.Adc_StartTemperatureSensorConversion_CallInstance); Mock.Adc_StartTemperatureSensorConversion_CallInstance = CMock_Guts_MemNext(Mock.Adc_StartTemperatureSensorConversion_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'Adc_StartTemperatureSensorConversion' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; }
bool Adc_TemperatureSensorSampleReady(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_Adc_TemperatureSensorSampleReady_CALL_INSTANCE* cmock_call_instance = (CMOCK_Adc_TemperatureSensorSampleReady_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.Adc_TemperatureSensorSampleReady_CallInstance); Mock.Adc_TemperatureSensorSampleReady_CallInstance = CMock_Guts_MemNext(Mock.Adc_TemperatureSensorSampleReady_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'Adc_TemperatureSensorSampleReady' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; return cmock_call_instance->ReturnVal; }
diskSpaceStatParce* getFileSystemsInfo(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_getFileSystemsInfo_CALL_INSTANCE* cmock_call_instance = (CMOCK_getFileSystemsInfo_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.getFileSystemsInfo_CallInstance); Mock.getFileSystemsInfo_CallInstance = CMock_Guts_MemNext(Mock.getFileSystemsInfo_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'getFileSystemsInfo' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; return cmock_call_instance->ReturnVal; }
//------------------------------------------------------- // CMock_Guts_MemEndOfChain //------------------------------------------------------- CMOCK_MEM_INDEX_TYPE CMock_Guts_MemEndOfChain(CMOCK_MEM_INDEX_TYPE root_index) { CMOCK_MEM_INDEX_TYPE index = root_index; CMOCK_MEM_INDEX_TYPE next_index; for (next_index = root_index; next_index != CMOCK_GUTS_NONE; next_index = CMock_Guts_MemNext(index)) { index = next_index; } return index; }
S_DATA mock_system_read_impl(S_DATA* src) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; UNITY_SET_DETAIL(CMockString_system_read); CMOCK_system_read_CALL_INSTANCE* cmock_call_instance = (CMOCK_system_read_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.system_read_CallInstance); Mock.system_read_CallInstance = CMock_Guts_MemNext(Mock.system_read_CallInstance); UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore); cmock_line = cmock_call_instance->LineNumber; { UNITY_SET_DETAILS(CMockString_system_read,CMockString_src); UNITY_TEST_ASSERT_EQUAL_PTR((void*)(cmock_call_instance->Expected_src), (void*)(src), cmock_line, CMockStringMismatch); } UNITY_CLR_DETAILS(); return cmock_call_instance->ReturnVal; }
void test_ThatWeCanAskForAllSortsOfSizes(void) { unsigned int i; unsigned int* first = NULL; unsigned int* next; unsigned int sizes[5] = {3, 1, 80, 5, 4}; unsigned int sizes_buffered[5] = {4, 4, 80, 8, 4}; unsigned int sum = 0; for (i = 0; i < 5; i++) { next = CMock_Guts_MemNew(sizes[i]); TEST_ASSERT_NOT_NULL(next); first = CMock_Guts_MemChain(first, next); TEST_ASSERT_NOT_NULL(first); sum += sizes_buffered[i] + 4; TEST_ASSERT_EQUAL(sum, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - sum, CMock_Guts_MemBytesFree()); } //show that we can't ask for too much memory TEST_ASSERT_NULL(CMock_Guts_MemNew(12)); TEST_ASSERT_NULL(CMock_Guts_MemNew(5)); //but we CAN ask for something that will still fit next = CMock_Guts_MemNew(4); TEST_ASSERT_NOT_NULL(next); first = CMock_Guts_MemChain(first, next); TEST_ASSERT_NOT_NULL(first); //verify we're used up now TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree()); //verify we can still walk through the elements allocated next = first; for (i = 0; i < 6; i++) { TEST_ASSERT_NOT_NULL(next); next = CMock_Guts_MemNext(next); } //there aren't any after that TEST_ASSERT_NULL(next); }
void LED_Toggle(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_LED_Toggle_CALL_INSTANCE* cmock_call_instance = (CMOCK_LED_Toggle_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.LED_Toggle_CallInstance); Mock.LED_Toggle_CallInstance = CMock_Guts_MemNext(Mock.LED_Toggle_CallInstance); if (Mock.LED_Toggle_IgnoreBool) { return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'LED_Toggle' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'LED_Toggle' called earlier than expected."); if (cmock_call_instance->CallOrder < GlobalVerifyOrder) UNITY_TEST_FAIL(cmock_line, "Function 'LED_Toggle' called later than expected."); }
void test_ThatCMockStopsReturningMoreDataWhenAskForMoreThanItHasLeftEvenIfNotAtExactEnd(void) { unsigned int i; CMOCK_MEM_INDEX_TYPE first = CMOCK_GUTS_NONE; CMOCK_MEM_INDEX_TYPE next; //we're asking for 12 bytes each time now (4 for index, 8 for data). //10 requests will give us 120 bytes used, which isn't enough for another 12 bytes if total memory is 128 for (i = 0; i < 10; i++) { TEST_ASSERT_EQUAL(i*12, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - i*12, CMock_Guts_MemBytesFree()); next = CMock_Guts_MemNew(8); TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); first = CMock_Guts_MemChain(first, next); TEST_ASSERT_MESSAGE(first != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); //verify writing data won't screw us up *((unsigned int*)CMock_Guts_GetAddressFor(next)) = i; } //verify we're at top of memory TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 8, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(8, CMock_Guts_MemBytesFree()); //The very next call will return a NONE, and any after that TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(8)); TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, CMock_Guts_MemNew(5)); //verify nothing has changed TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - 8, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(8, CMock_Guts_MemBytesFree()); //verify we can still walk through the elements allocated next = first; for (i = 0; i < 10; i++) { TEST_ASSERT_MESSAGE(next != CMOCK_GUTS_NONE, "Should Not Have Returned CMOCK_GUTS_NONE"); TEST_ASSERT_EQUAL(i, *((unsigned int*)CMock_Guts_GetAddressFor(next))); next = CMock_Guts_MemNext(next); } //there aren't any after that TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, next); }
void qeocore_remote_registration_init_cond(void) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeocore_remote_registration_init_cond_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeocore_remote_registration_init_cond_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeocore_remote_registration_init_cond_CallInstance); Mock.qeocore_remote_registration_init_cond_CallInstance = CMock_Guts_MemNext(Mock.qeocore_remote_registration_init_cond_CallInstance); if (Mock.qeocore_remote_registration_init_cond_IgnoreBool) { return; } if (Mock.qeocore_remote_registration_init_cond_CallbackFunctionPointer != NULL) { Mock.qeocore_remote_registration_init_cond_CallbackFunctionPointer(Mock.qeocore_remote_registration_init_cond_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeocore_remote_registration_init_cond' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; }
void test_ThatCMockStopsReturningMoreDataWhenItRunsOutOfMemory(void) { unsigned int i; unsigned int* first = NULL; unsigned int* next; //even though we are asking for one byte, we've told it to align to closest 4 bytes, therefore it will waste a byte each time //so each call will use 8 bytes (4 for the index, 1 for the data, and 3 wasted). //therefore we can safely allocated total/8 times. for (i = 0; i < (CMOCK_MEM_SIZE / 8); i++) { TEST_ASSERT_EQUAL(i*8, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE - i*8, CMock_Guts_MemBytesFree()); next = CMock_Guts_MemNew(1); TEST_ASSERT_NOT_NULL(next); first = CMock_Guts_MemChain(first, next); TEST_ASSERT_NOT_NULL(first); } //verify we're at top of memory TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree()); //The very next call will return a NULL, and any after that TEST_ASSERT_NULL(CMock_Guts_MemNew(1)); TEST_ASSERT_NULL(CMock_Guts_MemNew(1)); TEST_ASSERT_NULL(CMock_Guts_MemNew(1)); //verify nothing has changed TEST_ASSERT_EQUAL(CMOCK_MEM_SIZE, CMock_Guts_MemBytesUsed()); TEST_ASSERT_EQUAL(0, CMock_Guts_MemBytesFree()); //verify we can still walk through the elements allocated next = first; for (i = 0; i < (CMOCK_MEM_SIZE / 8); i++) { TEST_ASSERT_NOT_NULL(next); next = CMock_Guts_MemNext(next); } //there aren't any after that TEST_ASSERT_NULL(next); }
void qeocore_remote_registration_set_key(EVP_PKEY* key) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeocore_remote_registration_set_key_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeocore_remote_registration_set_key_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeocore_remote_registration_set_key_CallInstance); Mock.qeocore_remote_registration_set_key_CallInstance = CMock_Guts_MemNext(Mock.qeocore_remote_registration_set_key_CallInstance); if (Mock.qeocore_remote_registration_set_key_IgnoreBool) { return; } if (Mock.qeocore_remote_registration_set_key_CallbackFunctionPointer != NULL) { Mock.qeocore_remote_registration_set_key_CallbackFunctionPointer(key, Mock.qeocore_remote_registration_set_key_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeocore_remote_registration_set_key' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_key), (void*)(key), sizeof(EVP_PKEY), cmock_line, "Function 'qeocore_remote_registration_set_key' called with unexpected value for argument 'key'."); }
void qeo_deviceinfo_publish(qeo_factory_t* factory) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeo_deviceinfo_publish_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_deviceinfo_publish_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeo_deviceinfo_publish_CallInstance); Mock.qeo_deviceinfo_publish_CallInstance = CMock_Guts_MemNext(Mock.qeo_deviceinfo_publish_CallInstance); if (Mock.qeo_deviceinfo_publish_IgnoreBool) { return; } if (Mock.qeo_deviceinfo_publish_CallbackFunctionPointer != NULL) { Mock.qeo_deviceinfo_publish_CallbackFunctionPointer(factory, Mock.qeo_deviceinfo_publish_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeo_deviceinfo_publish' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_factory), (void*)(factory), sizeof(qeo_factory_t), cmock_line, "Function 'qeo_deviceinfo_publish' called with unexpected value for argument 'factory'."); }
void qeo_platform_security_update_state(qeo_platform_security_context_t context, qeo_platform_security_state state, qeo_platform_security_state_reason state_reason) { UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM; CMOCK_qeo_platform_security_update_state_CALL_INSTANCE* cmock_call_instance = (CMOCK_qeo_platform_security_update_state_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.qeo_platform_security_update_state_CallInstance); Mock.qeo_platform_security_update_state_CallInstance = CMock_Guts_MemNext(Mock.qeo_platform_security_update_state_CallInstance); if (Mock.qeo_platform_security_update_state_IgnoreBool) { return; } if (Mock.qeo_platform_security_update_state_CallbackFunctionPointer != NULL) { Mock.qeo_platform_security_update_state_CallbackFunctionPointer(context, state, state_reason, Mock.qeo_platform_security_update_state_CallbackCalls++); return; } UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'qeo_platform_security_update_state' called more times than expected."); cmock_line = cmock_call_instance->LineNumber; UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_context), (void*)(&context), sizeof(qeo_platform_security_context_t), cmock_line, "Function 'qeo_platform_security_update_state' called with unexpected value for argument 'context'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_state), (void*)(&state), sizeof(qeo_platform_security_state), cmock_line, "Function 'qeo_platform_security_update_state' called with unexpected value for argument 'state'."); UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_state_reason), (void*)(&state_reason), sizeof(qeo_platform_security_state_reason), cmock_line, "Function 'qeo_platform_security_update_state' called with unexpected value for argument 'state_reason'."); }