コード例 #1
0
/**
* To extract the argument of access or banked
*
* Input:
*	String	the whole argument
* 
* Return the value of access/banked
* Throw if value is invalid
*/
int extractAccessBanked(String *arguments){
	char location;
	char *returnChar;
	int returnInt;
	String *string;
	String *banked = stringNew(textNew("BANKED")); //1
	String *access = stringNew(textNew("ACCESS")); //0
	
	if(stringCharAt(arguments,0) == ',')
		stringRemoveChar(arguments);
		
	if(stringLength(arguments) == 0 ||stringCharAt(arguments,0) == ';')
		
		Throw(ERR_NO_ARGUMENT);
		
	stringTrimLeft(arguments);
	
	if(stringLength(arguments) == 0 ||stringCharAt(arguments,0) == ';')
		Throw(ERR_EMPTY_ARGUMENT);
		
	string = stringRemoveWordNotContaining(arguments,",;");
	
	stringTrim(string);
	
	if(stringLength(string) == 0){
		if(stringCharAt(arguments,0) == ',')
			stringRemoveChar(arguments);
		Throw(ERR_EMPTY_ARGUMENT);
	}
	
	else if(stringLength(string) == 6){
		
		if(stringIsEqual(string,banked))
			returnInt = 1;
		else if(stringIsEqual(string,access))
			returnInt = 0;
		else{
			returnChar = stringSubstringInChar(string,0,string->length);
			returnInt =  evaluate(returnChar);
		}
	}
	else{
		returnChar = stringSubstringInChar(string,0,string->length);
		returnInt = evaluate(returnChar);
	}
	
	if(stringCharAt(arguments,0) == ',')
		stringRemoveChar(arguments);
	
	free(string);
	return returnInt;

}
void test_stringIsEqual_should_return_not_equal_static(void) {
    int toCompare;
    Text *text = t"aBc";
    String *str = stringNew(text);
    Text *text1 = t"aabc";
    String *str1 = stringNew(text1);
    str1->start++;
    str1->length--;

    toCompare = stringIsEqual(str,str1);

    TEST_ASSERT_EQUAL(0,toCompare);
}
コード例 #3
0
static int equalString(void *str1, void *str2){
	return stringIsEqual((char*) str1, (char*) str2);
}