1 // temporarily disable optimizations altogether until a fine grain control
2 // is implemented on Makefile level only disabling the compiler option -Os
8 #define SourceStringSize 257 // test correct page passing (>256)
10 static char SourceString[SourceStringSize+1]; // +1 room for terminating null
11 static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer
19 for (i=0; i < SourceStringSize; ++i)
20 SourceString[i] = (i%128)+1;
24 ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!");
26 /* Ensure empty destination string */
27 DestinationString[0] = 0;
29 ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!");
31 /* Test concatenation to empty buffer */
33 strcat(DestinationString, SourceString);
35 ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!");
37 /* Test concatenation to non empty buffer */
39 p = strcat(DestinationString, SourceString);
41 ASSERT_AreEqual(2*SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!");
43 /* Test return value */
45 ASSERT_IsTrue(p == DestinationString,"Invalid return value!");
50 for(i=0; i < SourceStringSize; ++i)
52 unsigned position = j*SourceStringSize+i;
53 unsigned current = DestinationString[position];
54 unsigned expected = (i%128)+1;
55 ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);