lundi 2 mars 2015

How to run test cases in Socket-Client program in eclipse-cdt?



I made simple StringReverse C project in eclipse-cd and made to .so (shared library). I made test cases for StringReverse C project in eclipse-cdt. Tests runs successfully.


But, these C project and test cases I wants to run in Socket-Client Programming in eclipse-cdt. Suppose, I wants to pass test cases in Client side and that test cases find the C function in Server side. How can I make this..?


references for Server-Client Project :


http://ift.tt/1EIdNQE


My StringReverse C code :



int StringReverse (char *ptrToDestination, char *ptrToSource);

int StringReverse(char *ptrToDestination,char *ptrToSource)
{

int i,j;

if(NULL == (void *)ptrToSource) {
return ERR_NULL_POINTER;
}

if (LENGTH_OF_STRING <= strlen(ptrToSource)) {
return ERR_STRING_LENGTH;
}

if(NULL == (void *)ptrToDestination) {
return ERR_NULL_POINTER;
}

for(i=0; ptrToSource[i]; i++) {
}

for(i=i-1,j=0; i>=0; i--,j++) {
ptrToDestination[j] = ptrToSource[i];
}
ptrToDestination[j] ='\0';

if(strlen(ptrToSource) != strlen(ptrToDestination)) {
return ERR_STRING_LENGTH;
}
return SUCCESS;
}


My test case :



TEST(StringReverse, tst_StringReverse_PointerToString)
{
char *ptrToSource = "abcdefghijkl";
char *ptrToDestination = NULL;

CHECK(NULL != ptrToSource);

ptrToDestination = (char *) malloc((strlen(ptrToSource)+COUNT_FOR_NULL)*sizeof(char));

CHECK(NULL != ptrToDestination);

StatusOfStringReverseFunction = StringReverse(ptrToDestination, ptrToSource);

CHECK(strlen(ptrToDestination) == strlen(ptrToSource));
LONGS_EQUAL(SUCCESS, StatusOfStringReverseFunction);

free ((void *)ptrToDestination);
}

TEST(StringReverse, tst_StringReverse_Null)
{
char source[LENGTH_OF_STRING] = "";
char destination[LENGTH_OF_STRING];

StatusOfStringReverseFunction = StringReverse (destination, source);

LONGS_EQUAL(SUCCESS, StatusOfStringReverseFunction);
}


What is the solution ?




Aucun commentaire:

Enregistrer un commentaire