diff options
author | Simon Josefsson <simon@josefsson.org> | 2010-02-17 10:10:47 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2010-02-17 10:10:47 +0100 |
commit | db3a3b93e599669172d46d81c3db3eb661640996 (patch) | |
tree | e0d9da491762dead0f4f742555a17e32f8f782df /gl/tests | |
parent | 8728945992cce0019e0d286181d81dcd9d280d0d (diff) | |
download | gnutls-db3a3b93e599669172d46d81c3db3eb661640996.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl/tests')
-rw-r--r-- | gl/tests/test-getdelim.c | 19 | ||||
-rw-r--r-- | gl/tests/test-getline.c | 19 | ||||
-rw-r--r-- | gl/tests/test-gettimeofday.c | 8 |
3 files changed, 33 insertions, 13 deletions
diff --git a/gl/tests/test-getdelim.c b/gl/tests/test-getdelim.c index df9966497e..a5df49f1dd 100644 --- a/gl/tests/test-getdelim.c +++ b/gl/tests/test-getdelim.c @@ -33,13 +33,13 @@ int main (void) { FILE *f; - char *line = NULL; - size_t len = 0; + char *line; + size_t len; ssize_t result; /* Create test file. */ f = fopen ("test-getdelim.txt", "wb"); - if (!f || fwrite ("anbcnd\0f", 1, 8, f) != 8 || fclose (f) != 0) + if (!f || fwrite ("anAnbcnd\0f", 1, 10, f) != 10 || fclose (f) != 0) { fputs ("Failed to create sample file.\n", stderr); remove ("test-getdelim.txt"); @@ -54,13 +54,24 @@ main (void) } /* Test initial allocation, which must include trailing NUL. */ + line = NULL; + len = 0; result = getdelim (&line, &len, 'n', f); ASSERT (result == 2); ASSERT (strcmp (line, "an") == 0); ASSERT (2 < len); + free (line); - /* Test growth of buffer. */ + /* Test initial allocation again, with line = NULL and len != 0. */ + line = NULL; + len = (size_t)(~0) / 4; + result = getdelim (&line, &len, 'n', f); + ASSERT (result == 2); + ASSERT (strcmp (line, "An") == 0); + ASSERT (2 < len); free (line); + + /* Test growth of buffer. */ line = malloc (1); len = 1; result = getdelim (&line, &len, 'n', f); diff --git a/gl/tests/test-getline.c b/gl/tests/test-getline.c index 7112b52a4c..6a661ce530 100644 --- a/gl/tests/test-getline.c +++ b/gl/tests/test-getline.c @@ -33,13 +33,13 @@ int main (void) { FILE *f; - char *line = NULL; - size_t len = 0; + char *line; + size_t len; ssize_t result; /* Create test file. */ f = fopen ("test-getline.txt", "wb"); - if (!f || fwrite ("a\nbc\nd\0f", 1, 8, f) != 8 || fclose (f) != 0) + if (!f || fwrite ("a\nA\nbc\nd\0f", 1, 10, f) != 10 || fclose (f) != 0) { fputs ("Failed to create sample file.\n", stderr); remove ("test-getline.txt"); @@ -54,13 +54,24 @@ main (void) } /* Test initial allocation, which must include trailing NUL. */ + line = NULL; + len = 0; result = getline (&line, &len, f); ASSERT (result == 2); ASSERT (strcmp (line, "a\n") == 0); ASSERT (2 < len); + free (line); - /* Test growth of buffer, must not leak. */ + /* Test initial allocation again, with line = NULL and len != 0. */ + line = NULL; + len = (size_t)(~0) / 4; + result = getline (&line, &len, f); + ASSERT (result == 2); + ASSERT (strcmp (line, "A\n") == 0); + ASSERT (2 < len); free (line); + + /* Test growth of buffer, must not leak. */ line = malloc (1); len = 0; result = getline (&line, &len, f); diff --git a/gl/tests/test-gettimeofday.c b/gl/tests/test-gettimeofday.c index 2a07814bb9..ff2bc72b54 100644 --- a/gl/tests/test-gettimeofday.c +++ b/gl/tests/test-gettimeofday.c @@ -20,7 +20,8 @@ #include <sys/time.h> #include "signature.h" -SIGNATURE_CHECK (gettimeofday, int, (struct timeval *, void *)); +SIGNATURE_CHECK (gettimeofday, int, + (struct timeval *, GETTIMEOFDAY_TIMEZONE *)); #include <time.h> @@ -42,8 +43,5 @@ main (void) fprintf (stderr, "gettimeofday still clobbers the localtime buffer!\n"); return 1; } - else - { - return 0; - } + return 0; } |