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);
  }
}
Exemple #2
0
void assertEqualCoordinate(Coordinate expected, 	//expected instance
							Coordinate actual, 		//actual instance
							int line, 				//line number where error happens
							char * message)			// This is error message
	


	
{		
		UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, NULL);
		UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, NULL);
}
Exemple #3
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);
  }
}
Exemple #4
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 testAsserEqualOperatorToken(const char* str,OperatorToken* actual,int lineNo) {
    UNITY_TEST_ASSERT_NOT_NULL(actual,lineNo,"The token should not be NULL!");
    if( TOKEN_OPERATOR_TYPE != actual->type) {
        CUSTOM_TEST_FAIL(lineNo,"Expected %s was %s. The token type is not the same.",        \
                         getTokenTypeName(TOKEN_OPERATOR_TYPE),getTokenTypeName(actual->type));
    }
    UNITY_TEST_ASSERT_EQUAL_INT(strlen(str),actual->length,lineNo,"The length is not the same.");
    UNITY_TEST_ASSERT_EQUAL_STRING(str,actual->symbol,lineNo,"The operator is not the same");
}
Exemple #6
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.");}
void customTestAssertValue(void *value, ListElement *actual, int lineNo){

  Iterator *iter;

  if (value==NULL || actual==NULL){
    CUSTOM_TEST_FAIL("ERROR:The value or actual cannot be NULL.");
  }
  else{
    OperatorToken *opTokActual=((OperatorToken *)(actual->value));

    char *strValue=((StringToken *)(value))->name;
    int  intValue=((IntegerToken *)(value))->value;
    double  floatValue=((FloatToken *)(value))->value;

    char *charRightToken=((StringToken *)(opTokActual->token[1]))->name;
    int  intRightToken=((IntegerToken *)(opTokActual->token[1]))->value;
    double  floatRightToken=((FloatToken *)(opTokActual->token[1]))->value;

    iter=createIterator((LinkedList *)(opTokActual->token[1]));

    UNITY_TEST_ASSERT_EQUAL_STRING(":", opTokActual->symbol, lineNo, NULL);

    //test for VALUE token
    if(opTokActual->token[1]->type==TOKEN_STRING_TYPE){
      if(((Token *)(value))->type==TOKEN_STRING_TYPE){
        UNITY_TEST_ASSERT_EQUAL_STRING(strValue,charRightToken,lineNo, NULL);
      }
      else{
        CUSTOM_TEST_FAIL("ERROR:Actual value for VALUE was %s",charRightToken);
      }
    }
    else if(opTokActual->token[1]->type==TOKEN_INTEGER_TYPE){
      if(((Token *)(value))->type==TOKEN_INTEGER_TYPE){
        UNITY_TEST_ASSERT_EQUAL_INT(intValue,intRightToken, lineNo, NULL);
      }
      else{
        CUSTOM_TEST_FAIL("ERROR:Actual value for VALUE was %d",intRightToken);
      }
    }
    else if(opTokActual->token[1]->type==TOKEN_FLOAT_TYPE){
      if(((Token *)(value))->type==TOKEN_FLOAT_TYPE){
        UNITY_TEST_ASSERT_EQUAL_FLOAT(floatValue,floatRightToken, lineNo, NULL);
      }
      else{
        CUSTOM_TEST_FAIL("ERROR:Actual value for VALUE was %d",floatRightToken);
      }
    }
    else{
      CUSTOM_TEST_FAIL("ERROR:Unexpected VALUE Token type.Expected String,Integer or a Float Token.");
    }
  }

}
qeo_retcode_t sequence_member_accessor(qeocore_data_t* data, int index, qeocore_data_t** value, int get)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_sequence_member_accessor_CALL_INSTANCE* cmock_call_instance = (CMOCK_sequence_member_accessor_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.sequence_member_accessor_CallInstance);
  Mock.sequence_member_accessor_CallInstance = CMock_Guts_MemNext(Mock.sequence_member_accessor_CallInstance);
  if (Mock.sequence_member_accessor_IgnoreBool)
  {
    if (cmock_call_instance == NULL)
      return Mock.sequence_member_accessor_FinalReturn;
    memcpy(&Mock.sequence_member_accessor_FinalReturn, &cmock_call_instance->ReturnVal, sizeof(qeo_retcode_t));
    return cmock_call_instance->ReturnVal;
  }
  if (Mock.sequence_member_accessor_CallbackFunctionPointer != NULL)
  {
    return Mock.sequence_member_accessor_CallbackFunctionPointer(data, index, value, get, Mock.sequence_member_accessor_CallbackCalls++);
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'sequence_member_accessor' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(cmock_call_instance->Expected_data), (void*)(data), sizeof(qeocore_data_t), cmock_line, "Function 'sequence_member_accessor' called with unexpected value for argument 'data'.");
  UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_index, index, cmock_line, "Function 'sequence_member_accessor' called with unexpected value for argument 'index'.");
  UNITY_TEST_ASSERT_EQUAL_PTR(cmock_call_instance->Expected_value, value, cmock_line, "Function 'sequence_member_accessor' called with unexpected value for argument 'value'.");
  UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_get, get, cmock_line, "Function 'sequence_member_accessor' called with unexpected value for argument 'get'.");
  return cmock_call_instance->ReturnVal;
}
Exemple #9
0
static void test_open(dummy_vfs_t* instance, const char* path,
        bool should_be_called, bool should_be_opened, int line)
{
    const int flags = O_CREAT | O_TRUNC | O_RDWR;
    instance->called = false;
    int fd = esp_vfs_open(__getreent(), path, flags, 0);
    UNITY_TEST_ASSERT_EQUAL_INT(should_be_called, instance->called, line,
            "should_be_called check failed");
    if (should_be_called) {
        if (should_be_opened) {
            UNITY_TEST_ASSERT(fd >= 0, line, "should be opened");
        } else {
            UNITY_TEST_ASSERT(fd < 0, line, "should not be opened");
        }
    }
    esp_vfs_close(__getreent(), fd);
}
Exemple #10
0
static void test_opendir(dummy_vfs_t* instance, const char* path,
        bool should_be_called, bool should_be_opened, int line)
{
    instance->called = false;
    DIR* dir = opendir(path);
    UNITY_TEST_ASSERT_EQUAL_INT(should_be_called, instance->called, line,
            "should_be_called check failed");
    if (should_be_called) {
        if (should_be_opened) {
            UNITY_TEST_ASSERT(dir != NULL, line, "should be opened");
        } else {
            UNITY_TEST_ASSERT(dir == 0, line, "should not be opened");
        }
    }
    if (dir) {
        closedir(dir);
    }
}
qeocore_data_t* data_alloc(DDS_DynamicType type, int prep_data)
{
  UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
  CMOCK_data_alloc_CALL_INSTANCE* cmock_call_instance = (CMOCK_data_alloc_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.data_alloc_CallInstance);
  Mock.data_alloc_CallInstance = CMock_Guts_MemNext(Mock.data_alloc_CallInstance);
  if (Mock.data_alloc_IgnoreBool)
  {
    if (cmock_call_instance == NULL)
      return Mock.data_alloc_FinalReturn;
    Mock.data_alloc_FinalReturn = cmock_call_instance->ReturnVal;
    return cmock_call_instance->ReturnVal;
  }
  if (Mock.data_alloc_CallbackFunctionPointer != NULL)
  {
    return Mock.data_alloc_CallbackFunctionPointer(type, prep_data, Mock.data_alloc_CallbackCalls++);
  }
  UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, "Function 'data_alloc' called more times than expected.");
  cmock_line = cmock_call_instance->LineNumber;
  UNITY_TEST_ASSERT_EQUAL_MEMORY((void*)(&cmock_call_instance->Expected_type), (void*)(&type), sizeof(DDS_DynamicType), cmock_line, "Function 'data_alloc' called with unexpected value for argument 'type'.");
  UNITY_TEST_ASSERT_EQUAL_INT(cmock_call_instance->Expected_prep_data, prep_data, cmock_line, "Function 'data_alloc' called with unexpected value for argument 'prep_data'.");
  return cmock_call_instance->ReturnVal;
}
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'.");
  }
}
Exemple #13
0
void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line)
{
    UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, "Example Struct Failed For Field x");
    UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, "Example Struct Failed For Field y");
}
Exemple #14
0
void AssertEqualMyDataType(const MyDataType_T expected, const MyDataType_T actual, const unsigned short line)
{
  UNITY_TEST_ASSERT_EQUAL_INT(expected.length, actual.length, line, "MyDataType_T.length check failed");
  UNITY_TEST_ASSERT_EQUAL_MEMORY(expected.buffer, actual.buffer, expected.length, line, "MyDataType_T.buffer check failed");
}