Commit 20c1d1e0 authored by Ferenc Wagner's avatar Ferenc Wagner Committed by Alexandre Julliard

Added snprintf test.

parent 7803bb5e
......@@ -92,8 +92,43 @@ static void test_sprintf( void )
}
}
static void test_snprintf (void)
{
struct snprintf_test {
const char *format;
int expected;
struct {
int retval;
int render;
} todo;
};
/* Pre-2.1 libc behaviour, not C99 compliant. */
const struct snprintf_test tests[] = {{"short", 5, {0, 0}},
{"justfit", 7, {0, 0}},
{"justfits", 8, {0, 1}},
{"muchlonger", -1, {1, 1}}};
char buffer[8];
const int bufsiz = sizeof buffer;
unsigned int i;
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
const char *fmt = tests[i].format;
const int expect = tests[i].expected;
const int n = _snprintf (buffer, bufsiz, fmt);
const int valid = n < 0 ? bufsiz : (n == bufsiz ? n : n+1);
todo (tests[i].todo.retval ? "wine" : "none")
ok (n == expect, "\"%s\": expected %d, returned %d",
fmt, expect, n);
todo (tests[i].todo.render ? "wine" : "none")
ok (!memcmp (fmt, buffer, valid),
"\"%s\": rendered \"%.*s\"", fmt, valid, buffer);
};
}
START_TEST(scanf)
{
test_sscanf();
test_sprintf();
test_snprintf();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment