s3:smb2_flush: make use of file_fsp_smb2()
[Samba.git] / lib / replace / test / snprintf.c
blobd06630bcc98d54033fdb5c7e62ecb91eae13e01b
1 void foo(const char *format, ...)
3 va_list ap;
4 int len;
5 char buf[20];
6 long long l = 1234567890;
7 l *= 100;
9 va_start(ap, format);
10 len = vsnprintf(buf, 0, format, ap);
11 va_end(ap);
12 if (len != 5) exit(1);
14 va_start(ap, format);
15 len = vsnprintf(0, 0, format, ap);
16 va_end(ap);
17 if (len != 5) exit(2);
19 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
21 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
22 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
23 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
24 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
26 printf("1");
27 exit(0);
29 main() { foo("hello"); }