projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
strtod: aid debugging
[gnulib.git]
/
tests
/
test-vasprintf.c
diff --git
a/tests/test-vasprintf.c
b/tests/test-vasprintf.c
index
fc950a1
..
cfde4f4
100644
(file)
--- a/
tests/test-vasprintf.c
+++ b/
tests/test-vasprintf.c
@@
-1,5
+1,5
@@
/* Test of vasprintf() and asprintf() functions.
/* Test of vasprintf() and asprintf() functions.
- Copyright (C) 2007 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
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
@@
-20,20
+20,15
@@
#include <stdio.h>
#include <stdio.h>
+#include "signature.h"
+SIGNATURE_CHECK (asprintf, int, (char **, char const *, ...));
+SIGNATURE_CHECK (vasprintf, int, (char **, char const *, va_list));
+
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
static int
my_asprintf (char **result, const char *format, ...)
static int
my_asprintf (char **result, const char *format, ...)
@@
-61,6
+56,16
@@
test_vasprintf ()
ASSERT (strcmp (result, "12345") == 0);
free (result);
}
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
}
static void
@@
-77,6
+82,16
@@
test_asprintf ()
ASSERT (strcmp (result, "12345") == 0);
free (result);
}
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
}
int