]> git.sur5r.net Git - cc65/blob - test/val/lib_common_strcspn.c
temporarily disable optimizations altogether until a fine grain control
[cc65] / test / val / lib_common_strcspn.c
1 // temporarily disable optimizations altogether until a fine grain control
2 // is implemented on Makefile level only disabling the compiler option -Os
3 #pragma optimize (off)
4
5 #include <string.h>
6 #include "unittest.h"
7
8 #define EstimatedStringSize 384                         // test correct page passing (>256)
9
10 static char EstimatedString[EstimatedStringSize+1];     // +1 room for terminating null
11 static char* EmptyTestChars="";                         // strlen equivalent...
12 static char* TestChars="1234567890";                    // we like to find numbers
13
14 TEST
15 {
16     unsigned i;
17     
18     for (i=0; i < EstimatedStringSize; ++i)
19       EstimatedString[i] = (i%26)+'A';                 // put ABCD... into the string to be estimated
20
21     ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for non-participant case!");
22
23     EstimatedString[EstimatedStringSize/2] = TestChars[strlen(TestChars-1)];
24     ASSERT_AreEqual(EstimatedStringSize/2, strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for participant case!");
25
26     ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!");
27 }
28 ENDTEST
29
30