diff options
Diffstat (limited to 'tests/test_vsnprintf_static.c')
| -rw-r--r-- | tests/test_vsnprintf_static.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_vsnprintf_static.c b/tests/test_vsnprintf_static.c new file mode 100644 index 0000000..f1263a8 --- /dev/null +++ b/tests/test_vsnprintf_static.c | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <stdarg.h> | ||
| 4 | #include <unistd.h> | ||
| 5 | |||
| 6 | char buffer[12] = {0}; | ||
| 7 | |||
| 8 | int msg_valid(int n, const char * format, ... ) { | ||
| 9 | va_list args; | ||
| 10 | va_start (args, format); | ||
| 11 | vsnprintf(buffer, n, format, args); | ||
| 12 | va_end (args); | ||
| 13 | } | ||
| 14 | |||
| 15 | int msg(int n, const char * format, ... ) { | ||
| 16 | va_list args; | ||
| 17 | va_start (args, format); | ||
| 18 | CHK_FAIL_START | ||
| 19 | vsnprintf(buffer, n, format, args); | ||
| 20 | CHK_FAIL_END | ||
| 21 | va_end (args); | ||
| 22 | return ret; | ||
| 23 | } | ||
| 24 | |||
| 25 | int main(int argc, char** argv) { | ||
| 26 | msg_valid(sizeof(buffer), "%s", "1234567890ABCDEF"); | ||
| 27 | return msg(sizeof(buffer)+1, "%s", "1234567890ABCDEF"); | ||
| 28 | } | ||
