Example #1
0
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);
  }
}
Example #2
0
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;
}
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);
  }
}
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);
  }
}
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;
}
Example #6
0
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;
}
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;
}
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;
}
Example #9
0
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;
}
void assertStringEqual(const char *expected, String *actual, int line, const char *msg) {
	int i;
	const char *str = &actual->text->string[actual->start];
  
	if(strlen(expected) != actual->length)
		UNITY_TEST_FAIL(line, "Both strings are not of the same length.");
    
	for(i = 0; expected[i] != 0 && expected[i] == str[i]; i++);
	if(expected[i] != 0)
		UNITY_TEST_FAIL(line, "Both strings are not the same.");
}
Example #11
0
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.");
}
Example #12
0
void UnityMalloc_EndTest(void)
{
    malloc_fail_countdown = MALLOC_DONT_FAIL;
    if (malloc_count != 0)
    {
        UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "This test leaks!");
    }
}
Example #13
0
void assertAvlNode(const Node* expectedLeftChild,
					const Node* expectedRightChild,
					const int balanceFactor,
					const Node *actual,
					const UNITY_LINE_TYPE lineNumber){
if(actual == NULL)
UNITY_TEST_FAIL(lineNumber, "The 'actual' node is NULL.");
UNITY_TEST_ASSERT_EQUAL_PTR(expectedLeftChild, actual->leftChild, lineNumber,"The leftChild is not the same.");
UNITY_TEST_ASSERT_EQUAL_PTR(expectedRightChild, actual->rightChild, lineNumber,"The rightChild is not the same.");
UNITY_TEST_ASSERT_EQUAL_INT(balanceFactor, actual->balance, lineNumber,"Balance factor is not the same.");}
Example #14
0
char _RS232_ReadByte(int comport_number, int line){
	char data = -1;
	int count = 0;
	while(RS232_PollComport(comport_number, &data, 1) == 0 && count < MAX_TRIES)
		count++;
	if(count >= MAX_TRIES){
		RS232_CloseComport(COMPORT);
		UNITY_TEST_FAIL(line,"Attempt to read byte but comport seems not responsive");
	}
	return data;
}
Example #15
0
int System_AbortRequested(void)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_System_AbortRequested_CALL_INSTANCE* cmock_call_instance = (CMOCK_System_AbortRequested_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.System_AbortRequested_CallInstance);
  Mock.System_AbortRequested_CallInstance = CMock_Guts_MemNext(Mock.System_AbortRequested_CallInstance);
  if (Mock.System_AbortRequested_IgnoreBool)
  {
    if (cmock_call_instance == NULL)
      return Mock.System_AbortRequested_FinalReturn;
    Mock.System_AbortRequested_FinalReturn = cmock_call_instance->ReturnVal;
    return cmock_call_instance->ReturnVal;
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'System_AbortRequested' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'System_AbortRequested' called earlier than expected.");
  if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'System_AbortRequested' called later than expected.");
  return cmock_call_instance->ReturnVal;
}
Example #16
0
void I2CWriteInit(void)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_I2CWriteInit_CALL_INSTANCE* cmock_call_instance = (CMOCK_I2CWriteInit_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.I2CWriteInit_CallInstance);
  Mock.I2CWriteInit_CallInstance = CMock_Guts_MemNext(Mock.I2CWriteInit_CallInstance);
  if (Mock.I2CWriteInit_IgnoreBool)
  {
    return;
  }
  if (Mock.I2CWriteInit_CallbackFunctionPointer != NULL)
  {
    Mock.I2CWriteInit_CallbackFunctionPointer(Mock.I2CWriteInit_CallbackCalls++);
    return;
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'I2CWriteInit' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'I2CWriteInit' called earlier than expected.");
  if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'I2CWriteInit' called later than expected.");
}
Example #17
0
void InitI2C(uint8_t address)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_InitI2C_CALL_INSTANCE* cmock_call_instance = (CMOCK_InitI2C_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.InitI2C_CallInstance);
  Mock.InitI2C_CallInstance = CMock_Guts_MemNext(Mock.InitI2C_CallInstance);
  if (Mock.InitI2C_IgnoreBool)
  {
    return;
  }
  if (Mock.InitI2C_CallbackFunctionPointer != NULL)
  {
    Mock.InitI2C_CallbackFunctionPointer(address, Mock.InitI2C_CallbackCalls++);
    return;
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'InitI2C' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'InitI2C' called earlier than expected.");
  if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'InitI2C' called later than expected.");
  UNITY_TEST_ASSERT_EQUAL_HEX8(cmock_call_instance->Expected_address, address, cmock_line, "Function 'InitI2C' called with unexpected value for argument 'address'.");
}
void evaluate3(char* expression)
{
    UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
    CMOCK_evaluate3_CALL_INSTANCE* cmock_call_instance = (CMOCK_evaluate3_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.evaluate3_CallInstance);
    Mock.evaluate3_CallInstance = CMock_Guts_MemNext(Mock.evaluate3_CallInstance);
    if (Mock.evaluate3_IgnoreBool)
    {
        return;
    }
    if (Mock.evaluate3_CallbackFunctionPointer != NULL)
    {
        Mock.evaluate3_CallbackFunctionPointer(expression, Mock.evaluate3_CallbackCalls++);
        return;
    }
    UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'evaluate3' called more times than expected.");
    cmock_line = cmock_call_instance->LineNumber;
    if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
        UNITY_TEST_FAIL(cmock_line, "Function 'evaluate3' called earlier than expected.");
    if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
        UNITY_TEST_FAIL(cmock_line, "Function 'evaluate3' called later than expected.");
    UNITY_TEST_ASSERT_EQUAL_STRING(cmock_call_instance->Expected_expression, expression, cmock_line, "Function 'evaluate3' called with unexpected value for argument 'expression'.");
}
void operatorPush(Token* token)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_operatorPush_CALL_INSTANCE* cmock_call_instance = (CMOCK_operatorPush_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.operatorPush_CallInstance);
  Mock.operatorPush_CallInstance = CMock_Guts_MemNext(Mock.operatorPush_CallInstance);
  if (Mock.operatorPush_IgnoreBool)
  {
    return;
  }
  if (Mock.operatorPush_CallbackFunctionPointer != NULL)
  {
    Mock.operatorPush_CallbackFunctionPointer(token, Mock.operatorPush_CallbackCalls++);
    return;
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'operatorPush' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'operatorPush' called earlier than expected.");
  if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'operatorPush' called later than expected.");
  UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_token), (void*)(token), sizeof(Token), cmock_line, "Function 'operatorPush' called with unexpected value for argument 'token'.");
}
Example #20
0
void UnityPointer_Set(void** pointer, void* newValue, UNITY_LINE_TYPE line)
{
    if (pointer_index >= MAX_POINTERS)
    {
        UNITY_TEST_FAIL(line, "Too many pointers set");
    }
    else
    {
        pointer_store[pointer_index].pointer = pointer;
        pointer_store[pointer_index].old_value = *pointer;
        *pointer = newValue;
        pointer_index++;
    }
}
void Draw_Int(int cmock_arg1)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_Draw_Int_CALL_INSTANCE* cmock_call_instance = (CMOCK_Draw_Int_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.Draw_Int_CallInstance);
  Mock.Draw_Int_CallInstance = CMock_Guts_MemNext(Mock.Draw_Int_CallInstance);
  if (Mock.Draw_Int_IgnoreBool)
  {
    return;
  }
  if (Mock.Draw_Int_CallbackFunctionPointer != NULL)
  {
    Mock.Draw_Int_CallbackFunctionPointer(cmock_arg1, Mock.Draw_Int_CallbackCalls++);
    return;
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'Draw_Int' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  if (cmock_call_instance->CallOrder > ++GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'Draw_Int' called earlier than expected.");
  if (cmock_call_instance->CallOrder < GlobalVerifyOrder)
    UNITY_TEST_FAIL(cmock_line, "Function 'Draw_Int' called later than expected.");
  {
    UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_cmock_arg1, cmock_arg1, cmock_line, "Function 'Draw_Int' called with unexpected value for argument 'cmock_arg1'.");
  }
}
Example #22
0
void unity_free(void* mem)
{
    int overrun;

    if (mem == NULL)
    {
        return;
    }

    overrun = isOverrun(mem);
    release_memory(mem);
    if (overrun)
    {
        UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during free()");
    }
}
Example #23
0
void* unity_realloc(void* oldMem, size_t size)
{
    Guard* guard = (Guard*)oldMem;
    void* newMem;

    if (oldMem == NULL) return unity_malloc(size);

    guard--;
    if (isOverrun(oldMem))
    {
        release_memory(oldMem);
        UNITY_TEST_FAIL(Unity.CurrentTestLineNumber, "Buffer overrun detected during realloc()");
    }

    if (size == 0)
    {
        release_memory(oldMem);
        return NULL;
    }

    if (guard->size >= size) return oldMem;

#ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */
    if (oldMem == unity_heap + heap_index - guard->size - sizeof(end) &&
        heap_index + size - guard->size <= UNITY_INTERNAL_HEAP_SIZE_BYTES)
    {
        release_memory(oldMem); /* Not thread-safe, like unity_heap generally */
        return unity_malloc(size); /* No memcpy since data is in place */
    }
#endif
    newMem = unity_malloc(size);
    if (newMem == NULL) return NULL; /* Do not release old memory */
    memcpy(newMem, oldMem, guard->size);
    release_memory(oldMem);
    return newMem;
}