ust-fd: Add close_range declaration
[lttng-ust.git] / tests / unit / snprintf / snprintf.c
CommitLineData
c0c0989a
MJ
1/*
2 * SPDX-License-Identifier: LGPL-2.1-or-later
a09dac63 3 *
c0c0989a 4 * Copyright (C) 2009 Pierre-Marc Fournier
a09dac63
PMF
5 */
6
bf0d695d
PMF
7#include <stdio.h>
8#include <string.h>
9d315d6d 9#include "common/safe-snprintf.h"
bf0d695d 10
d23b20e9
JG
11#include "tap.h"
12
4b4a1337 13int main(void)
bf0d695d
PMF
14{
15 char buf[100];
3c99db22
MJ
16 const char expected_str[] = "header 9999, hello, 005, ' 9'";
17 const char test_fmt_str[] = "header %d, %s, %03d, '%*d'";
d23b20e9
JG
18
19 plan_tests(1);
bf0d695d 20
3c99db22 21 ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 5, 9);
d23b20e9 22
3c99db22 23 ok(strcmp(buf, expected_str) == 0, "Got expected output string with format string \"%s\"", test_fmt_str);
bf0d695d 24
bf746e7d 25 return exit_status();
bf0d695d 26}
This page took 0.039609 seconds and 5 git commands to generate.