int main()
{
- char s[11] = "xxxxxxxxxxx";
+ char s[] = "xxxxxxxxxxx";
BEGIN_TESTS;
TESTCASE( memcpy( s, abcde, 6 ) == s );
TESTCASE( s[4] == 'e' );
int main()
{
- char s[10] = "xxxxabcde";
+ char s[] = "xxxxabcde";
BEGIN_TESTS;
TESTCASE( memmove( s, s + 4, 5 ) == s );
TESTCASE( s[0] == 'a' );
int main()
{
- char s[10] = "xxxxxxxxx";
+ char s[] = "xxxxxxxxx";
BEGIN_TESTS;
TESTCASE( memset( s, 'o', 10 ) == s );
TESTCASE( s[9] == 'o' );
return rc;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "xx\0xxxxxx";
+ BEGIN_TESTS;
+ TESTCASE( strcat( s, abcde ) == s );
+ TESTCASE( s[2] == 'a' );
+ TESTCASE( s[6] == 'e' );
+ TESTCASE( s[7] == '\0' );
+ TESTCASE( s[8] == 'x' );
+ s[0] = '\0';
+ TESTCASE( strcat( s, abcdx ) == s );
+ TESTCASE( s[4] == 'x' );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( strcat( s, "\0" ) == s );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( s[6] == 'e' );
+ return TEST_RESULTS;
}
#endif
return NULL;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char abccd[] = "abccd";
+ BEGIN_TESTS;
+ TESTCASE( strchr( abccd, 'x' ) == NULL );
+ TESTCASE( strchr( abccd, 'a' ) == &abccd[0] );
+ TESTCASE( strchr( abccd, 'd' ) == &abccd[4] );
+ TESTCASE( strchr( abccd, '\0' ) == &abccd[5] );
+ TESTCASE( strchr( abccd, 'c' ) == &abccd[2] );
+ return TEST_RESULTS;
}
#endif
return ( *s1 - *s2 );
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char cmpabcde[] = "abcde";
+ char empty[] = "";
+ BEGIN_TESTS;
+ TESTCASE( strcmp( abcde, cmpabcde ) == 0 );
+ TESTCASE( strcmp( abcde, abcdx ) < 0 );
+ TESTCASE( strcmp( abcdx, abcde ) > 0 );
+ TESTCASE( strcmp( empty, abcde ) < 0 );
+ TESTCASE( strcmp( abcde, empty ) > 0 );
+ return TEST_RESULTS;
}
#endif
return strcmp( s1, s2 );
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char cmpabcde[] = "abcde";
+ char empty[] = "";
+ BEGIN_TESTS;
+ TESTCASE( strcmp( abcde, cmpabcde ) == 0 );
+ TESTCASE( strcmp( abcde, abcdx ) < 0 );
+ TESTCASE( strcmp( abcdx, abcde ) > 0 );
+ TESTCASE( strcmp( empty, abcde ) < 0 );
+ TESTCASE( strcmp( abcde, empty ) > 0 );
+ return TEST_RESULTS;
}
#endif
return rc;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "xxxxx";
+ BEGIN_TESTS;
+ TESTCASE( strcpy( s, "" ) == s );
+ TESTCASE( s[0] == '\0' );
+ TESTCASE( s[1] == 'x' );
+ TESTCASE( strcpy( s, abcde ) == s );
+ TESTCASE( s[0] == 'a' );
+ TESTCASE( s[4] == 'e' );
+ TESTCASE( s[5] == '\0' );
+ return TEST_RESULTS;
}
#endif
return len;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ BEGIN_TESTS;
+ TESTCASE( strcspn( abcde, "x" ) == 5 );
+ TESTCASE( strcspn( abcde, "xyz" ) == 5 );
+ TESTCASE( strcspn( abcde, "zyx" ) == 5 );
+ TESTCASE( strcspn( abcdx, "x" ) == 4 );
+ TESTCASE( strcspn( abcdx, "xyz" ) == 4 );
+ TESTCASE( strcspn( abcdx, "zyx" ) == 4 );
+ TESTCASE( strcspn( abcde, "a" ) == 0 );
+ TESTCASE( strcspn( abcde, "abc" ) == 0 );
+ TESTCASE( strcspn( abcde, "cba" ) == 0 );
+ return TEST_RESULTS;
}
#endif
return rc;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ BEGIN_TESTS;
+ TESTCASE( strlen( abcde ) == 5 );
+ TESTCASE( strlen( "" ) == 0 );
+ return TEST_RESULTS;
}
#endif
return rc;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "xx\0xxxxxx";
+ BEGIN_TESTS;
+ TESTCASE( strncat( s, abcde, 10 ) == s );
+ TESTCASE( s[2] == 'a' );
+ TESTCASE( s[6] == 'e' );
+ TESTCASE( s[7] == '\0' );
+ TESTCASE( s[8] == 'x' );
+ s[0] = '\0';
+ TESTCASE( strncat( s, abcdx, 10 ) == s );
+ TESTCASE( s[4] == 'x' );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( strncat( s, "\0", 10 ) == s );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( s[6] == 'e' );
+ TESTCASE( strncat( s, abcde, 0 ) == s );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( s[6] == 'e' );
+ TESTCASE( strncat( s, abcde, 3 ) == s );
+ TESTCASE( s[5] == 'a' );
+ TESTCASE( s[7] == 'c' );
+ TESTCASE( s[8] == '\0' );
+ return TEST_RESULTS;
}
#endif
}
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char cmpabcde[] = "abcde";
+ char empty[] = "";
+ char x[] = "x";
+ BEGIN_TESTS;
+ TESTCASE( strncmp( abcde, cmpabcde, 5 ) == 0 );
+ TESTCASE( strncmp( abcde, abcdx, 5 ) < 0 );
+ TESTCASE( strncmp( abcdx, abcde, 5 ) > 0 );
+ TESTCASE( strncmp( empty, abcde, 5 ) < 0 );
+ TESTCASE( strncmp( abcde, empty, 5 ) > 0 );
+ TESTCASE( strncmp( abcde, abcdx, 4 ) == 0 );
+ TESTCASE( strncmp( abcde, x, 0 ) == 0 );
+ TESTCASE( strncmp( abcde, x, 1 ) < 0 );
+ return TEST_RESULTS;
}
#endif
return NULL;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ BEGIN_TESTS;
+ TESTCASE( strpbrk( abcde, "x" ) == NULL );
+ TESTCASE( strpbrk( abcde, "xyz" ) == NULL );
+ TESTCASE( strpbrk( abcdx, "x" ) == &abcdx[4] );
+ TESTCASE( strpbrk( abcdx, "xyz" ) == &abcdx[4] );
+ TESTCASE( strpbrk( abcdx, "zyx" ) == &abcdx[4] );
+ TESTCASE( strpbrk( abcde, "a" ) == &abcde[0] );
+ TESTCASE( strpbrk( abcde, "abc" ) == &abcde[0] );
+ TESTCASE( strpbrk( abcde, "cba" ) == &abcde[0] );
+ return TEST_RESULTS;
}
#endif
return NULL;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char abccd[] = "abccd";
+ BEGIN_TESTS;
+ TESTCASE( strrchr( abcde, '\0' ) == &abcde[5] );
+ TESTCASE( strrchr( abcde, 'e' ) == &abcde[4] );
+ TESTCASE( strrchr( abcde, 'a' ) == &abcde[0] );
+ TESTCASE( strrchr( abccd, 'c' ) == &abccd[3] );
+ return TEST_RESULTS;
}
#endif
return len;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ BEGIN_TESTS;
+ TESTCASE( strspn( abcde, "abc" ) == 3 );
+ TESTCASE( strspn( abcde, "b" ) == 0 );
+ TESTCASE( strspn( abcde, abcde ) == 5 );
+ return TEST_RESULTS;
}
#endif
return NULL;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "abcabcabcdabcde";
+ BEGIN_TESTS;
+ TESTCASE( strstr( s, "x" ) == NULL );
+ TESTCASE( strstr( s, "xyz" ) == NULL );
+ TESTCASE( strstr( s, "a" ) == &s[0] );
+ TESTCASE( strstr( s, "abc" ) == &s[0] );
+ TESTCASE( strstr( s, "abcd" ) == &s[6] );
+ TESTCASE( strstr( s, "abcde" ) == &s[10] );
+ return TEST_RESULTS;
}
#endif
{
static char * tmp = NULL;
const char * p = s2;
- size_t len;
if ( s1 != NULL )
{
return ( tmp = NULL );
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "_a_bc__d_";
+ BEGIN_TESTS;
+ TESTCASE( strtok( s, "_" ) == &s[1] );
+ TESTCASE( s[1] == 'a' );
+ TESTCASE( s[2] == '\0' );
+ TESTCASE( strtok( NULL, "_" ) == &s[3] );
+ TESTCASE( s[3] == 'b' );
+ TESTCASE( s[4] == 'c' );
+ TESTCASE( s[5] == '\0' );
+ TESTCASE( strtok( NULL, "_" ) == &s[7] );
+ TESTCASE( s[6] == '_' );
+ TESTCASE( s[7] == 'd' );
+ TESTCASE( s[8] == '\0' );
+ TESTCASE( strtok( NULL, "_" ) == NULL );
+ return TEST_RESULTS;
}
#endif
return len;
}
-#warning Test driver missing.
-
#ifdef TEST
+#include <_PDCLIB_test.h>
+
int main()
{
- return 0;
+ char s[] = "xxxxxxxxxxx";
+ BEGIN_TESTS;
+ TESTCASE( strxfrm( NULL, "123456789012", 0 ) == 12 );
+ TESTCASE( strxfrm( s, "123456789012", 12 ) == 12 );
+ /*
+ The following test case is true in *this* implementation, but doesn't have to.
+ TESTCASE( s[0] == 'x' );
+ */
+ TESTCASE( strxfrm( s, "1234567890", 11 ) == 10 );
+ TESTCASE( s[0] == '1' );
+ TESTCASE( s[9] == '0' );
+ TESTCASE( s[10] == '\0' );
+ return TEST_RESULTS;
}
#endif
+