mirror of
https://github.com/samba-team/samba.git
synced 2025-01-07 17:18:11 +03:00
6cc68c1ccf
Found by Joe Guo during preperation for automated code coverage output. In order to allow the Makefile wrapper to work we need to rename the test directory to tests. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
30 lines
749 B
C
30 lines
749 B
C
void foo(const char *format, ...)
|
|
{
|
|
va_list ap;
|
|
int len;
|
|
char buf[20];
|
|
long long l = 1234567890;
|
|
l *= 100;
|
|
|
|
va_start(ap, format);
|
|
len = vsnprintf(buf, 0, format, ap);
|
|
va_end(ap);
|
|
if (len != 5) exit(1);
|
|
|
|
va_start(ap, format);
|
|
len = vsnprintf(0, 0, format, ap);
|
|
va_end(ap);
|
|
if (len != 5) exit(2);
|
|
|
|
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
|
|
|
|
if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
|
|
if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
|
|
if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
|
|
if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
|
|
|
|
printf("1");
|
|
exit(0);
|
|
}
|
|
int main(void) { foo("hello"); }
|