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 384 // test correct page passing (>256, multiple of 128 here)
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 "unlimted" concatenation to empty buffer */
33 strncat(DestinationString, SourceString, 1024);
35 ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!");
37 /* Test limited concatenation to non empty buffer */
39 p = strncat(DestinationString, SourceString, 128);
41 ASSERT_AreEqual(SourceStringSize+128, 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!");
49 for(i=0; i < strlen(DestinationString); ++i)
51 unsigned current = DestinationString[i];
52 unsigned expected = (i%128)+1;
53 ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA i);