File: test_snprintf.c

package info (click to toggle)
fluidsynth 2.4.4%2Bdfsg-1%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,328 kB
  • sloc: ansic: 43,529; cpp: 1,434; xml: 1,020; makefile: 71; sh: 46
file content (23 lines) | stat: -rw-r--r-- 484 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#include "test.h"
#include "utils/fluid_sys.h"

// this test makes sure FLUID_SNPRINTF uses a proper C99 compliant implementation

int main(void)
{
    char buf[2 + 1];

    int ret = FLUID_SNPRINTF(buf, sizeof(buf), "99");
    TEST_ASSERT(ret == 2);

    TEST_ASSERT(buf[2] == '\0');

    ret = FLUID_SNPRINTF(buf, sizeof(buf), "999");
    TEST_ASSERT(ret == 3);

    // output truncated, buffer must be NULL terminated!
    TEST_ASSERT(buf[2] == '\0');

    return EXIT_SUCCESS;
}