| 1 | /* |
| 2 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | * |
| 4 | * Copyright (C) 2009 Pierre-Marc Fournier |
| 5 | */ |
| 6 | |
| 7 | #include <stdio.h> |
| 8 | #include <string.h> |
| 9 | #include "common/safe-snprintf.h" |
| 10 | |
| 11 | #include "tap.h" |
| 12 | |
| 13 | int main(void) |
| 14 | { |
| 15 | char buf[100]; |
| 16 | const char expected_str[] = "header 9999, hello, 005, ' 9'"; |
| 17 | const char test_fmt_str[] = "header %d, %s, %03d, '%*d'"; |
| 18 | |
| 19 | plan_tests(1); |
| 20 | |
| 21 | ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 5, 9); |
| 22 | |
| 23 | ok(strcmp(buf, expected_str) == 0, "Got expected output string with format string \"%s\"", test_fmt_str); |
| 24 | |
| 25 | return exit_status(); |
| 26 | } |