ntdll/tests: Add test for _snprintf.
This commit is contained in:
parent
3c2dc4a7b3
commit
09bb38d12b
|
@ -59,6 +59,7 @@ static LPWSTR (WINAPIV *p_wcsrchr)(LPCWSTR, WCHAR);
|
||||||
|
|
||||||
static void (__cdecl *p_qsort)(void *,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
|
static void (__cdecl *p_qsort)(void *,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
|
||||||
static void* (__cdecl *p_bsearch)(void *,void*,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
|
static void* (__cdecl *p_bsearch)(void *,void*,size_t,size_t, int(__cdecl *compar)(const void *, const void *) );
|
||||||
|
static int (__cdecl *p__snprintf)(char *, size_t, const char *, ...);
|
||||||
|
|
||||||
|
|
||||||
static void InitFunctionPtrs(void)
|
static void InitFunctionPtrs(void)
|
||||||
|
@ -96,6 +97,8 @@ static void InitFunctionPtrs(void)
|
||||||
p_wcsrchr= (void *)GetProcAddress(hntdll, "wcsrchr");
|
p_wcsrchr= (void *)GetProcAddress(hntdll, "wcsrchr");
|
||||||
p_qsort= (void *)GetProcAddress(hntdll, "qsort");
|
p_qsort= (void *)GetProcAddress(hntdll, "qsort");
|
||||||
p_bsearch= (void *)GetProcAddress(hntdll, "bsearch");
|
p_bsearch= (void *)GetProcAddress(hntdll, "bsearch");
|
||||||
|
|
||||||
|
p__snprintf = (void *)GetProcAddress(hntdll, "_snprintf");
|
||||||
} /* if */
|
} /* if */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1270,6 +1273,34 @@ static void test_bsearch(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test__snprintf(void)
|
||||||
|
{
|
||||||
|
const char *origstring = "XXXXXXXXXXXX";
|
||||||
|
const char *teststring = "hello world";
|
||||||
|
char buffer[32];
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = p__snprintf(NULL, 0, teststring);
|
||||||
|
ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
|
||||||
|
|
||||||
|
res = p__snprintf(NULL, 1, teststring);
|
||||||
|
ok(res == lstrlenA(teststring) /* WinXP */ || res < 0 /* Vista and greater */,
|
||||||
|
"_snprintf returned %d, expected %d or < 0.\n", res, lstrlenA(teststring));
|
||||||
|
|
||||||
|
res = p__snprintf(buffer, strlen(teststring) - 1, teststring);
|
||||||
|
ok(res < 0, "_snprintf returned %d, expected < 0.\n", res);
|
||||||
|
|
||||||
|
strcpy(buffer, origstring);
|
||||||
|
res = p__snprintf(buffer, strlen(teststring), teststring);
|
||||||
|
ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
|
||||||
|
ok(!strcmp(buffer, "hello worldX"), "_snprintf returned buffer '%s', expected 'hello worldX'.\n", buffer);
|
||||||
|
|
||||||
|
strcpy(buffer, origstring);
|
||||||
|
res = p__snprintf(buffer, strlen(teststring) + 1, teststring);
|
||||||
|
ok(res == lstrlenA(teststring), "_snprintf returned %d, expected %d.\n", res, lstrlenA(teststring));
|
||||||
|
ok(!strcmp(buffer, teststring), "_snprintf returned buffer '%s', expected '%s'.\n", buffer, teststring);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(string)
|
START_TEST(string)
|
||||||
{
|
{
|
||||||
InitFunctionPtrs();
|
InitFunctionPtrs();
|
||||||
|
@ -1304,4 +1335,6 @@ START_TEST(string)
|
||||||
test_qsort();
|
test_qsort();
|
||||||
if (p_bsearch)
|
if (p_bsearch)
|
||||||
test_bsearch();
|
test_bsearch();
|
||||||
|
if (p__snprintf)
|
||||||
|
test__snprintf();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue