]> git.sur5r.net Git - cc65/blob - test/val/lib_common_strspn.c
goto.c warning fix for implicit truncation
[cc65] / test / val / lib_common_strspn.c
1 #include <string.h>
2 #include "unittest.h"
3
4 #define EstimatedStringSize 384                         // test correct page passing (>256)
5
6 static char EstimatedString[EstimatedStringSize+1];     // +1 room for terminating null
7 static char* EmptyTestChars="";                         // empty test case...
8 static char* TestChars="1234567890";                    // we like to find numbers
9
10 TEST
11 {
12     unsigned i;
13     
14     for (i=0; i < EstimatedStringSize; ++i)
15       EstimatedString[i] = (i%10)+'0';                 // put 0123... into the string to be estimated
16
17     ASSERT_AreEqual(strlen(EstimatedString), strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for all participant case!");
18
19     EstimatedString[EstimatedStringSize/2] = 'X';
20     ASSERT_AreEqual(EstimatedStringSize/2, strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for breaking case!");
21
22     ASSERT_AreEqual(0, strspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!");
23 }
24 ENDTEST