4 #define SourceStringSize 257 // test correct page passing (>256)
6 static char SourceString[SourceStringSize+1]; // +1 room for terminating null
7 static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer
15 for (i=0; i < SourceStringSize; ++i)
16 SourceString[i] = (i%128)+1;
20 ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!");
22 /* Ensure empty destination string */
23 DestinationString[0] = 0;
25 ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!");
27 /* Test concatenation to empty buffer */
29 strcat(DestinationString, SourceString);
31 ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!");
33 /* Test concatenation to non empty buffer */
35 p = strcat(DestinationString, SourceString);
37 ASSERT_AreEqual(2*SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!");
39 /* Test return value */
41 ASSERT_IsTrue(p == DestinationString,"Invalid return value!");
46 for(i=0; i < SourceStringSize; ++i)
48 unsigned position = j*SourceStringSize+i;
49 unsigned current = DestinationString[position];
50 unsigned expected = (i%128)+1;
51 ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);