diff options
| author | jvoisin | 2025-10-31 15:18:10 +0100 |
|---|---|---|
| committer | jvoisin | 2025-11-11 14:09:16 +0100 |
| commit | fe3e4269959ea7534722aa2664a3cac69d9109cf (patch) | |
| tree | cfb4a11fa1c2a14798b1bf1b56facdd9ea8ea170 /tests/test_vsprintf.c | |
| parent | 558f28473a1dea3d314156f2f3c45f078433ff57 (diff) | |
Add a testsuite
Co-Authored-By: q66 <q66@chimera-linux.org>
Diffstat (limited to 'tests/test_vsprintf.c')
| -rw-r--r-- | tests/test_vsprintf.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_vsprintf.c b/tests/test_vsprintf.c new file mode 100644 index 0000000..bd5b893 --- /dev/null +++ b/tests/test_vsprintf.c | |||
| @@ -0,0 +1,29 @@ | |||
| 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 | return 0; | ||
| 14 | } | ||
| 15 | |||
| 16 | int msg(const char * format, ... ) { | ||
| 17 | va_list args; | ||
| 18 | va_start (args, format); | ||
| 19 | CHK_FAIL_START | ||
| 20 | vsprintf(buffer, format, args); | ||
| 21 | CHK_FAIL_END | ||
| 22 | va_end (args); | ||
| 23 | return ret; | ||
| 24 | } | ||
| 25 | |||
| 26 | int main(int argc, char** argv) { | ||
| 27 | msg_valid("%s", "1234567"); | ||
| 28 | return msg("%s", "1234567890ABCDEF"); | ||
| 29 | } | ||
