summaryrefslogtreecommitdiff
path: root/lib/tests
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2001-10-31 23:49:52 +0000
committerwtc%netscape.com <devnull@localhost>2001-10-31 23:49:52 +0000
commit6ec6e81fe9c6d72770c3c57f3993b47c512e295f (patch)
treede10bff08d7e20755d8a4dbd5387488b18c3dbe0 /lib/tests
parent9973dd577464cbfcd318015e8e97f5db2a3394a8 (diff)
downloadnspr-hg-6ec6e81fe9c6d72770c3c57f3993b47c512e295f.tar.gz
Added lib/tests/Makefile to the list of makefiles to be generated by
configure. Modified files: configure configure.in Bugzilla bug 106372: added new function PL_strtok_r. The function was implemented by Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>. Modified files: lib/libc/include/plstr.h lib/libc/src/Makefile.in lib/tests/string.c Added file: lib/libc/src/strtok.c
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/string.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/tests/string.c b/lib/tests/string.c
index 895189c3..0e2c3a55 100644
--- a/lib/tests/string.c
+++ b/lib/tests/string.c
@@ -3003,6 +3003,59 @@ PRBool test_030(void)
return PR_TRUE;
}
+/* PL_strtok_r */
+PRBool test_031(void)
+{
+ static const char *tokens[] = {
+ "wtc", "relyea", "nelsonb", "jpierre", "nicolson",
+ "ian.mcgreer", "kirk.erickson", "sonja.mirtitsch", "mhein"
+ };
+
+ static const char *seps[] = {
+ ", ", ",", " ", "\t", ",,,", " ,", " ", " \t\t", ","
+ };
+
+ static const char s2[] = ", \t";
+
+ char string[ 1024 ];
+ char *s1;
+ char *token;
+ char *lasts;
+ unsigned int i;
+
+ printf("Test 031 (PL_strtok_r) ..."); fflush(stdout);
+
+ /* Build the string. */
+ string[0] = '\0';
+ for( i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++ )
+ {
+ PL_strcat(string, tokens[i]);
+ PL_strcat(string, seps[i]);
+ }
+
+ /* Scan the string for tokens. */
+ i = 0;
+ s1 = string;
+ while( (token = PL_strtok_r(s1, s2, &lasts)) != NULL)
+ {
+ if( strcmp(token, tokens[i]) != 0 )
+ {
+ printf("FAIL wrong token scanned\n");
+ return PR_FALSE;
+ }
+ i++;
+ s1 = NULL;
+ }
+ if( i != sizeof(tokens)/sizeof(tokens[0]) )
+ {
+ printf("FAIL wrong number of tokens scanned\n");
+ return PR_FALSE;
+ }
+
+ printf("PASS\n");
+ return PR_TRUE;
+}
+
int
main
(
@@ -3044,6 +3097,7 @@ main
&& test_028()
&& test_029()
&& test_030()
+ && test_031()
)
{
printf("Suite passed.\n");