X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-vasprintf.c;h=cfde4f49c7ef4ca99ccf273e4e1a8c1c983a913a;hb=74d509383fe30bb5511a978b52e4f8ecae37826b;hp=46483e4586225ebd8768d885e8a7a46eaa524aa4;hpb=89ae4589dd58d12e7cbcf0e92c1d828c1e430f97;p=gnulib.git diff --git a/tests/test-vasprintf.c b/tests/test-vasprintf.c index 46483e458..cfde4f49c 100644 --- a/tests/test-vasprintf.c +++ b/tests/test-vasprintf.c @@ -1,5 +1,5 @@ /* Test of vasprintf() and asprintf() functions. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,17 +28,7 @@ SIGNATURE_CHECK (vasprintf, int, (char **, char const *, va_list)); #include #include -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "macros.h" static int my_asprintf (char **result, const char *format, ...) @@ -66,6 +56,16 @@ test_vasprintf () ASSERT (strcmp (result, "12345") == 0); free (result); } + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = my_asprintf (&result, "%08lx", 12345UL); + ASSERT (retval == 8); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00003039") == 0); + free (result); + } } static void @@ -82,6 +82,16 @@ test_asprintf () ASSERT (strcmp (result, "12345") == 0); free (result); } + + for (repeat = 0; repeat <= 8; repeat++) + { + char *result; + int retval = asprintf (&result, "%08lx", 12345UL); + ASSERT (retval == 8); + ASSERT (result != NULL); + ASSERT (strcmp (result, "00003039") == 0); + free (result); + } } int