⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtlstr.c

📁 Wine-20031016
💻 C
📖 第 1 页 / 共 5 页
字号:
	    uni_str.Buffer = uni_buf;	} else {	    uni_str.Buffer = NULL;	} /* if */	result = pRtlUnicodeStringToAnsiString(&ansi_str, &uni_str, ustr2astr[test_num].doalloc);	ok(result == ustr2astr[test_num].result,	   "(test %d): RtlUnicodeStringToAnsiString(ansi, uni, %d) has result %lx, expected %lx",	   test_num, ustr2astr[test_num].doalloc, result, ustr2astr[test_num].result);	ok(ansi_str.Length == ustr2astr[test_num].res_Length,	   "(test %d): RtlUnicodeStringToAnsiString(ansi, uni, %d) ansi has Length %d, expected %d",	   test_num, ustr2astr[test_num].doalloc, ansi_str.Length, ustr2astr[test_num].res_Length);	ok(ansi_str.MaximumLength == ustr2astr[test_num].res_MaximumLength,	   "(test %d): RtlUnicodeStringToAnsiString(ansi, uni, %d) ansi has MaximumLength %d, expected %d",	   test_num, ustr2astr[test_num].doalloc, ansi_str.MaximumLength, ustr2astr[test_num].res_MaximumLength);	ok(memcmp(ansi_str.Buffer, ustr2astr[test_num].res_buf, ustr2astr[test_num].res_buf_size) == 0,	   "(test %d): RtlUnicodeStringToAnsiString(ansi, uni, %d) has ansi \"%s\" expected \"%s\"",	   test_num, ustr2astr[test_num].doalloc, ansi_str.Buffer, ustr2astr[test_num].res_buf);    } /* for */}typedef struct {    int dest_Length;    int dest_MaximumLength;    int dest_buf_size;    const char *dest_buf;    const char *src;    int res_Length;    int res_MaximumLength;    int res_buf_size;    const char *res_buf;    NTSTATUS result;} app_asc2str_t;static const app_asc2str_t app_asc2str[] = {    { 5, 12, 15,  "TestS01234abcde", "tring", 10, 12, 15,  "TestStringabcde", STATUS_SUCCESS},    { 5, 11, 15,  "TestS01234abcde", "tring", 10, 11, 15,  "TestStringabcde", STATUS_SUCCESS},    { 5, 10, 15,  "TestS01234abcde", "tring", 10, 10, 15,  "TestStringabcde", STATUS_SUCCESS},    { 5,  9, 15,  "TestS01234abcde", "tring",  5,  9, 15,  "TestS01234abcde", STATUS_BUFFER_TOO_SMALL},    { 5,  0, 15,  "TestS01234abcde", "tring",  5,  0, 15,  "TestS01234abcde", STATUS_BUFFER_TOO_SMALL},    { 5, 14, 15,  "TestS01234abcde", "tring", 10, 14, 15,  "TestStringabcde", STATUS_SUCCESS},    { 5, 14, 15,  "TestS01234abcde",    NULL,  5, 14, 15,  "TestS01234abcde", STATUS_SUCCESS},    { 5, 14, 15,               NULL,    NULL,  5, 14, 15,               NULL, STATUS_SUCCESS},    { 5, 12, 15, "Tst\0S01234abcde", "tr\0i",  7, 12, 15, "Tst\0Str234abcde", STATUS_SUCCESS},};#define NB_APP_ASC2STR (sizeof(app_asc2str)/sizeof(*app_asc2str))static void test_RtlAppendAsciizToString(void){    CHAR dest_buf[257];    STRING dest_str;    NTSTATUS result;    size_t test_num;    for (test_num = 0; test_num < NB_APP_ASC2STR; test_num++) {	dest_str.Length        = app_asc2str[test_num].dest_Length;	dest_str.MaximumLength = app_asc2str[test_num].dest_MaximumLength;	if (app_asc2str[test_num].dest_buf != NULL) {	    memcpy(dest_buf, app_asc2str[test_num].dest_buf, app_asc2str[test_num].dest_buf_size);	    dest_buf[app_asc2str[test_num].dest_buf_size] = '\0';	    dest_str.Buffer = dest_buf;	} else {	    dest_str.Buffer = NULL;	} /* if */	result = pRtlAppendAsciizToString(&dest_str, app_asc2str[test_num].src);	ok(result == app_asc2str[test_num].result,	   "(test %d): RtlAppendAsciizToString(dest, src) has result %lx, expected %lx",	   test_num, result, app_asc2str[test_num].result);	ok(dest_str.Length == app_asc2str[test_num].res_Length,	   "(test %d): RtlAppendAsciizToString(dest, src) dest has Length %d, expected %d",	   test_num, dest_str.Length, app_asc2str[test_num].res_Length);	ok(dest_str.MaximumLength == app_asc2str[test_num].res_MaximumLength,	   "(test %d): RtlAppendAsciizToString(dest, src) dest has MaximumLength %d, expected %d",	   test_num, dest_str.MaximumLength, app_asc2str[test_num].res_MaximumLength);	if (dest_str.Buffer == dest_buf) {	    ok(memcmp(dest_buf, app_asc2str[test_num].res_buf, app_asc2str[test_num].res_buf_size) == 0,	       "(test %d): RtlAppendAsciizToString(dest, src) has dest \"%s\" expected \"%s\"",	       test_num, dest_buf, app_asc2str[test_num].res_buf);	} else {	    ok(dest_str.Buffer == app_asc2str[test_num].res_buf,	       "(test %d): RtlAppendAsciizToString(dest, src) dest has Buffer %p expected %p",	       test_num, dest_str.Buffer, app_asc2str[test_num].res_buf);	} /* if */    } /* for */}typedef struct {    int dest_Length;    int dest_MaximumLength;    int dest_buf_size;    const char *dest_buf;    int src_Length;    int src_MaximumLength;    int src_buf_size;    const char *src_buf;    int res_Length;    int res_MaximumLength;    int res_buf_size;    const char *res_buf;    NTSTATUS result;} app_str2str_t;static const app_str2str_t app_str2str[] = {    { 5, 12, 15,  "TestS01234abcde", 5, 5, 7, "tringZY", 10, 12, 15,   "TestStringabcde", STATUS_SUCCESS},    { 5, 11, 15,  "TestS01234abcde", 5, 5, 7, "tringZY", 10, 11, 15,   "TestStringabcde", STATUS_SUCCESS},    { 5, 10, 15,  "TestS01234abcde", 5, 5, 7, "tringZY", 10, 10, 15,   "TestStringabcde", STATUS_SUCCESS},    { 5,  9, 15,  "TestS01234abcde", 5, 5, 7, "tringZY",  5,  9, 15,   "TestS01234abcde", STATUS_BUFFER_TOO_SMALL},    { 5,  0, 15,  "TestS01234abcde", 0, 0, 7, "tringZY",  5,  0, 15,   "TestS01234abcde", STATUS_SUCCESS},    { 5, 14, 15,  "TestS01234abcde", 0, 0, 7, "tringZY",  5, 14, 15,   "TestS01234abcde", STATUS_SUCCESS},    { 5, 14, 15,  "TestS01234abcde", 0, 0, 7,      NULL,  5, 14, 15,   "TestS01234abcde", STATUS_SUCCESS},    { 5, 14, 15,               NULL, 0, 0, 7,      NULL,  5, 14, 15,                NULL, STATUS_SUCCESS},    { 5, 12, 15, "Tst\0S01234abcde", 4, 4, 7, "tr\0iZY",  9, 12, 15, "Tst\0Str\0i4abcde", STATUS_SUCCESS},};#define NB_APP_STR2STR (sizeof(app_str2str)/sizeof(*app_str2str))static void test_RtlAppendStringToString(void){    CHAR dest_buf[257];    CHAR src_buf[257];    STRING dest_str;    STRING src_str;    NTSTATUS result;    size_t test_num;    for (test_num = 0; test_num < NB_APP_STR2STR; test_num++) {	dest_str.Length        = app_str2str[test_num].dest_Length;	dest_str.MaximumLength = app_str2str[test_num].dest_MaximumLength;	if (app_str2str[test_num].dest_buf != NULL) {	    memcpy(dest_buf, app_str2str[test_num].dest_buf, app_str2str[test_num].dest_buf_size);	    dest_buf[app_str2str[test_num].dest_buf_size] = '\0';	    dest_str.Buffer = dest_buf;	} else {	    dest_str.Buffer = NULL;	} /* if */	src_str.Length         = app_str2str[test_num].src_Length;	src_str.MaximumLength  = app_str2str[test_num].src_MaximumLength;	if (app_str2str[test_num].src_buf != NULL) {	    memcpy(src_buf, app_str2str[test_num].src_buf, app_str2str[test_num].src_buf_size);	    src_buf[app_str2str[test_num].src_buf_size] = '\0';	    src_str.Buffer = src_buf;	} else {	    src_str.Buffer = NULL;	} /* if */	result = pRtlAppendStringToString(&dest_str, &src_str);	ok(result == app_str2str[test_num].result,	   "(test %d): RtlAppendStringToString(dest, src) has result %lx, expected %lx",	   test_num, result, app_str2str[test_num].result);	ok(dest_str.Length == app_str2str[test_num].res_Length,	   "(test %d): RtlAppendStringToString(dest, src) dest has Length %d, expected %d",	   test_num, dest_str.Length, app_str2str[test_num].res_Length);	ok(dest_str.MaximumLength == app_str2str[test_num].res_MaximumLength,	   "(test %d): RtlAppendStringToString(dest, src) dest has MaximumLength %d, expected %d",	   test_num, dest_str.MaximumLength, app_str2str[test_num].res_MaximumLength);	if (dest_str.Buffer == dest_buf) {	    ok(memcmp(dest_buf, app_str2str[test_num].res_buf, app_str2str[test_num].res_buf_size) == 0,	       "(test %d): RtlAppendStringToString(dest, src) has dest \"%s\" expected \"%s\"",	       test_num, dest_buf, app_str2str[test_num].res_buf);	} else {	    ok(dest_str.Buffer == app_str2str[test_num].res_buf,	       "(test %d): RtlAppendStringToString(dest, src) dest has Buffer %p expected %p",	       test_num, dest_str.Buffer, app_str2str[test_num].res_buf);	} /* if */    } /* for */}typedef struct {    int dest_Length;    int dest_MaximumLength;    int dest_buf_size;    const char *dest_buf;    const char *src;    int res_Length;    int res_MaximumLength;    int res_buf_size;    const char *res_buf;    NTSTATUS result;} app_uni2str_t;static const app_uni2str_t app_uni2str[] = {    { 4, 12, 14,     "Fake0123abcdef",    "Ustr\0",  8, 12, 14,  "FakeUstr\0\0cdef", STATUS_SUCCESS},    { 4, 11, 14,     "Fake0123abcdef",    "Ustr\0",  8, 11, 14,  "FakeUstr\0\0cdef", STATUS_SUCCESS},    { 4, 10, 14,     "Fake0123abcdef",    "Ustr\0",  8, 10, 14,  "FakeUstr\0\0cdef", STATUS_SUCCESS},/* In the following test the native function writes beyond MaximumLength *  { 4,  9, 14,     "Fake0123abcdef",    "Ustr\0",  8,  9, 14,    "FakeUstrabcdef", STATUS_SUCCESS}, */    { 4,  8, 14,     "Fake0123abcdef",    "Ustr\0",  8,  8, 14,    "FakeUstrabcdef", STATUS_SUCCESS},    { 4,  7, 14,     "Fake0123abcdef",    "Ustr\0",  4,  7, 14,    "Fake0123abcdef", STATUS_BUFFER_TOO_SMALL},    { 4,  0, 14,     "Fake0123abcdef",    "Ustr\0",  4,  0, 14,    "Fake0123abcdef", STATUS_BUFFER_TOO_SMALL},    { 4, 14, 14,     "Fake0123abcdef",    "Ustr\0",  8, 14, 14,  "FakeUstr\0\0cdef", STATUS_SUCCESS},    { 4, 14, 14,     "Fake0123abcdef",        NULL,  4, 14, 14,    "Fake0123abcdef", STATUS_SUCCESS},    { 4, 14, 14,                 NULL,        NULL,  4, 14, 14,                NULL, STATUS_SUCCESS},    { 4, 14, 14,     "Fake0123abcdef", "U\0stri\0", 10, 14, 14, "FakeU\0stri\0\0ef", STATUS_SUCCESS},    { 6, 14, 16, "Te\0\0stabcdefghij",  "St\0\0ri",  8, 14, 16, "Te\0\0stSt\0\0efghij", STATUS_SUCCESS},};#define NB_APP_UNI2STR (sizeof(app_uni2str)/sizeof(*app_uni2str))static void test_RtlAppendUnicodeToString(void){    WCHAR dest_buf[257];    UNICODE_STRING dest_str;    NTSTATUS result;    size_t test_num;    for (test_num = 0; test_num < NB_APP_UNI2STR; test_num++) {	dest_str.Length        = app_uni2str[test_num].dest_Length;	dest_str.MaximumLength = app_uni2str[test_num].dest_MaximumLength;	if (app_uni2str[test_num].dest_buf != NULL) {	    memcpy(dest_buf, app_uni2str[test_num].dest_buf, app_uni2str[test_num].dest_buf_size);	    dest_buf[app_uni2str[test_num].dest_buf_size/sizeof(WCHAR)] = '\0';	    dest_str.Buffer = dest_buf;	} else {	    dest_str.Buffer = NULL;	} /* if */	result = pRtlAppendUnicodeToString(&dest_str, (LPCWSTR) app_uni2str[test_num].src);	ok(result == app_uni2str[test_num].result,	   "(test %d): RtlAppendUnicodeToString(dest, src) has result %lx, expected %lx",	   test_num, result, app_uni2str[test_num].result);	ok(dest_str.Length == app_uni2str[test_num].res_Length,	   "(test %d): RtlAppendUnicodeToString(dest, src) dest has Length %d, expected %d",	   test_num, dest_str.Length, app_uni2str[test_num].res_Length);	ok(dest_str.MaximumLength == app_uni2str[test_num].res_MaximumLength,	   "(test %d): RtlAppendUnicodeToString(dest, src) dest has MaximumLength %d, expected %d",	   test_num, dest_str.MaximumLength, app_uni2str[test_num].res_MaximumLength);	if (dest_str.Buffer == dest_buf) {	    ok(memcmp(dest_buf, app_uni2str[test_num].res_buf, app_uni2str[test_num].res_buf_size) == 0,	       "(test %d): RtlAppendUnicodeToString(dest, src) has dest \"%s\" expected \"%s\"",	       test_num, (char *) dest_buf, app_uni2str[test_num].res_buf);	} else {	    ok(dest_str.Buffer == (WCHAR *) app_uni2str[test_num].res_buf,	       "(test %d): RtlAppendUnicodeToString(dest, src) dest has Buffer %p expected %p",	       test_num, dest_str.Buffer, app_uni2str[test_num].res_buf);	} /* if */    } /* for */}typedef struct {    int dest_Length;    int dest_MaximumLength;    int dest_buf_size;    const char *dest_buf;    int src_Length;    int src_MaximumLength;    int src_buf_size;    const char *src_buf;    int res_Length;    int res_MaximumLength;    int res_buf_size;    const char *res_buf;    NTSTATUS result;} app_ustr2str_t;static const app_ustr2str_t app_ustr2str[] = {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -