aboutsummaryrefslogtreecommitdiff
path: root/string/tester.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-03 09:05:11 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-03 09:05:11 +0000
commitfb4fb5428d50d3d0c092a60f5ef4410f250ed2c4 (patch)
tree5729b64ff57a4aa16283a7f2904c7acba8fca711 /string/tester.c
parent5f73e77144a76a585f108c971e6c7aa5c9008944 (diff)
downloadglibc-fb4fb5428d50d3d0c092a60f5ef4410f250ed2c4.zip
glibc-fb4fb5428d50d3d0c092a60f5ef4410f250ed2c4.tar.gz
glibc-fb4fb5428d50d3d0c092a60f5ef4410f250ed2c4.tar.bz2
Update.
2001-11-02 Jakub Jelinek <jakub@redhat.com> * string/bits/string2.h (__strndup): If n is smaller than len, set len to n + 1. * string/tester.c (test_strndup): New function. (main): Call it. * sunrpc/rpc_main.c: Optimize variable definitions a bit.
Diffstat (limited to 'string/tester.c')
-rw-r--r--string/tester.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/string/tester.c b/string/tester.c
index bd2445f..39ae0d8 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -1257,6 +1257,30 @@ test_bzero (void)
}
static void
+test_strndup (void)
+{
+ char *p, *q;
+ it = "strndup";
+ p = strndup("abcdef", 12);
+ check(p != NULL, 1);
+ if (p != NULL)
+ {
+ equal(p, "abcdef", 2);
+ q = strndup(p + 1, 2);
+ check(q != NULL, 3);
+ if (q != NULL)
+ equal(q, "bc", 4);
+ free (q);
+ }
+ free (p);
+ p = strndup("abc def", 3);
+ check(p != NULL, 5);
+ if (p != NULL)
+ equal(p, "abc", 6);
+ free (p);
+}
+
+static void
test_bcmp (void)
{
it = "bcmp";
@@ -1382,6 +1406,9 @@ main (void)
/* bcmp - somewhat like memcmp. */
test_bcmp ();
+ /* strndup. */
+ test_strndup ();
+
/* strerror - VERY system-dependent. */
test_strerror ();