diff options
| author | jvoisin | 2023-07-09 18:03:34 +0200 |
|---|---|---|
| committer | jvoisin | 2023-07-09 18:03:34 +0200 |
| commit | f9f83da31803062d1fb665ad612ccede5e445757 (patch) | |
| tree | 13216a6e43b1d17e17ef8b26c80fcc30c6abf7df /tests/test_vsprintf.c | |
| parent | 33acec595b47ec97ae57a98ec396a26f6d8e309e (diff) | |
Add tests for stdio.h
Diffstat (limited to 'tests/test_vsprintf.c')
| -rw-r--r-- | tests/test_vsprintf.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_vsprintf.c b/tests/test_vsprintf.c new file mode 100644 index 0000000..740816f --- /dev/null +++ b/tests/test_vsprintf.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(const char * format, ... ) { | ||
| 9 | va_list args; | ||
| 10 | va_start (args, format); | ||
| 11 | vsprintf(buffer, 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 | vsprintf(buffer, 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("%s", "1234567"); | ||
| 27 | return msg("%s", "1234567890ABCDEF"); | ||
| 28 | } | ||
