Added snprintf test.
This commit is contained in:
parent
7803bb5e5a
commit
20c1d1e0f9
dlls/msvcrt/tests
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue