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

📄 large_int.c

📁 Wine-20031016
💻 C
📖 第 1 页 / 共 2 页
字号:
 *  { 2, 0xFFFFFFFFFF, 40, 41, "1111111111111111111111111111111111111111\0--------------------------", STATUS_SUCCESS}, */    { 8,  0x80000000U, 11, 12, "20000000000\0-------------------------------------------------------", STATUS_SUCCESS},/* *  { 8,  -2147483647, 22, 23, "1777777777760000000001\0--------------------------------------------", STATUS_SUCCESS}, *  { 8,           -2, 22, 23, "1777777777777777777776\0--------------------------------------------", STATUS_SUCCESS}, *  { 8,           -1, 22, 23, "1777777777777777777777\0--------------------------------------------", STATUS_SUCCESS}, */    { 8,            0,  1, 12, "0\0-----------------------------------------------------------------", STATUS_SUCCESS},    { 8,            1,  1, 12, "1\0-----------------------------------------------------------------", STATUS_SUCCESS},    { 8,   2147483646, 11, 12, "17777777776\0-------------------------------------------------------", STATUS_SUCCESS},    { 8,   2147483647, 11, 12, "17777777777\0-------------------------------------------------------", STATUS_SUCCESS},    { 8,  2147483648U, 11, 12, "20000000000\0-------------------------------------------------------", STATUS_SUCCESS},    { 8,  2147483649U, 11, 12, "20000000001\0-------------------------------------------------------", STATUS_SUCCESS},    { 8,  4294967294U, 11, 12, "37777777776\0-------------------------------------------------------", STATUS_SUCCESS},    { 8,  4294967295U, 11, 12, "37777777777\0-------------------------------------------------------", STATUS_SUCCESS},    {10,  0x80000000U, 10, 11, "2147483648\0--------------------------------------------------------", STATUS_SUCCESS},    {10,  -2147483647, 20, 21, "18446744071562067969\0----------------------------------------------", STATUS_SUCCESS},    {10,           -2, 20, 21, "18446744073709551614\0----------------------------------------------", STATUS_SUCCESS},    {10,           -1, 20, 21, "18446744073709551615\0----------------------------------------------", STATUS_SUCCESS},    {10,            0,  1, 11, "0\0-----------------------------------------------------------------", STATUS_SUCCESS},    {10,            1,  1, 11, "1\0-----------------------------------------------------------------", STATUS_SUCCESS},    {10,   2147483646, 10, 11, "2147483646\0--------------------------------------------------------", STATUS_SUCCESS},    {10,   2147483647, 10, 11, "2147483647\0--------------------------------------------------------", STATUS_SUCCESS},    {10,  2147483648U, 10, 11, "2147483648\0--------------------------------------------------------", STATUS_SUCCESS},    {10,  2147483649U, 10, 11, "2147483649\0--------------------------------------------------------", STATUS_SUCCESS},    {10,  4294967294U, 10, 11, "4294967294\0--------------------------------------------------------", STATUS_SUCCESS},    {10,  4294967295U, 10, 11, "4294967295\0--------------------------------------------------------", STATUS_SUCCESS},    {16,                  0,  1,  9, "0\0-----------------------------------------------------------------", STATUS_SUCCESS},    {16,                  1,  1,  9, "1\0-----------------------------------------------------------------", STATUS_SUCCESS},    {16,         2147483646,  8,  9, "7FFFFFFE\0----------------------------------------------------------", STATUS_SUCCESS},    {16,         2147483647,  8,  9, "7FFFFFFF\0----------------------------------------------------------", STATUS_SUCCESS},    {16,         0x80000000,  8,  9, "80000000\0----------------------------------------------------------", STATUS_SUCCESS},    {16,         0x80000001,  8,  9, "80000001\0----------------------------------------------------------", STATUS_SUCCESS},    {16,         0xFFFFFFFE,  8,  9, "FFFFFFFE\0----------------------------------------------------------", STATUS_SUCCESS},    {16,         0xFFFFFFFF,  8,  9, "FFFFFFFF\0----------------------------------------------------------", STATUS_SUCCESS},/* *  {16,        0x100000000,  9, 10, "100000000\0---------------------------------------------------------", STATUS_SUCCESS}, *  {16,      0xBADDEADBEEF, 11, 12, "BADDEADBEEF\0-------------------------------------------------------", STATUS_SUCCESS}, *  {16, 0x8000000000000000, 16, 17, "8000000000000000\0--------------------------------------------------", STATUS_SUCCESS}, *  {16, 0xFEDCBA9876543210, 16, 17, "FEDCBA9876543210\0--------------------------------------------------", STATUS_SUCCESS}, *  {16, 0xFFFFFFFF80000001, 16, 17, "FFFFFFFF80000001\0--------------------------------------------------", STATUS_SUCCESS}, *  {16, 0xFFFFFFFFFFFFFFFE, 16, 17, "FFFFFFFFFFFFFFFE\0--------------------------------------------------", STATUS_SUCCESS}, *  {16, 0xFFFFFFFFFFFFFFFF, 16, 17, "FFFFFFFFFFFFFFFF\0--------------------------------------------------", STATUS_SUCCESS}, */    { 2,        32768, 16, 17, "1000000000000000\0--------------------------------------------------", STATUS_SUCCESS},    { 2,        32768, 16, 16, "1000000000000000---------------------------------------------------",  STATUS_SUCCESS},    { 2,        65536, 17, 18, "10000000000000000\0-------------------------------------------------", STATUS_SUCCESS},    { 2,        65536, 17, 17, "10000000000000000--------------------------------------------------",  STATUS_SUCCESS},    { 2,       131072, 18, 19, "100000000000000000\0------------------------------------------------", STATUS_SUCCESS},    { 2,       131072, 18, 18, "100000000000000000-------------------------------------------------",  STATUS_SUCCESS},    {16,   0xffffffff,  8,  9, "FFFFFFFF\0----------------------------------------------------------", STATUS_SUCCESS},    {16,   0xffffffff,  8,  8, "FFFFFFFF-----------------------------------------------------------",  STATUS_SUCCESS},    {16,   0xffffffff,  8,  7, "-------------------------------------------------------------------",  STATUS_BUFFER_OVERFLOW},    {16,          0xa,  1,  2, "A\0-----------------------------------------------------------------", STATUS_SUCCESS},    {16,          0xa,  1,  1, "A------------------------------------------------------------------",  STATUS_SUCCESS},    {16,            0,  1,  0, "-------------------------------------------------------------------",  STATUS_BUFFER_OVERFLOW},    {20,   0xdeadbeef,  0,  9, "-------------------------------------------------------------------",  STATUS_INVALID_PARAMETER},    {-8,     07654321,  0, 12, "-------------------------------------------------------------------",  STATUS_INVALID_PARAMETER},};#define NB_LARGEINT2STR (sizeof(largeint2str)/sizeof(*largeint2str))static void one_RtlInt64ToUnicodeString_test(int test_num, const largeint2str_t *largeint2str){    int pos;    WCHAR expected_str_Buffer[LARGE_STRI_BUFFER_LENGTH + 1];    UNICODE_STRING expected_unicode_string;    STRING expected_ansi_str;    WCHAR str_Buffer[LARGE_STRI_BUFFER_LENGTH + 1];    UNICODE_STRING unicode_string;    STRING ansi_str;    NTSTATUS result;    for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {	expected_str_Buffer[pos] = largeint2str->Buffer[pos];    } /* for */    expected_unicode_string.Length = largeint2str->Length * sizeof(WCHAR);    expected_unicode_string.MaximumLength = largeint2str->MaximumLength * sizeof(WCHAR);    expected_unicode_string.Buffer = expected_str_Buffer;    pRtlUnicodeStringToAnsiString(&expected_ansi_str, &expected_unicode_string, 1);    for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {	str_Buffer[pos] = '-';    } /* for */    unicode_string.Length = 0;    unicode_string.MaximumLength = largeint2str->MaximumLength * sizeof(WCHAR);    unicode_string.Buffer = str_Buffer;    if (largeint2str->base == 0) {	result = pRtlInt64ToUnicodeString(largeint2str->value, 10, &unicode_string);    } else {	result = pRtlInt64ToUnicodeString(largeint2str->value, largeint2str->base, &unicode_string);    } /* if */    pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);    if (result == STATUS_BUFFER_OVERFLOW) {	/* On BUFFER_OVERFLOW the string Buffer should be unchanged */	for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {	    expected_str_Buffer[pos] = '-';	} /* for */	/* w2k: The native function has two reasons for BUFFER_OVERFLOW: */	/* If the value is too large to convert: The Length is unchanged */	/* If str is too small to hold the string: Set str->Length to the length */	/* the string would have (which can be larger than the MaximumLength). */	/* To allow all this in the tests we do the following: */	if (expected_unicode_string.Length >= 64) {	    /* The value is too large to convert only triggerd when testing native */	    /* Length is not filled with the expected string length (garbage?) */	    expected_unicode_string.Length = unicode_string.Length;	} /* if */    } else {	ok(result == largeint2str->result,	   "(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) has result %lx, expected: %lx",	   test_num, largeint2str->value, largeint2str->base, result, largeint2str->result);	if (result == STATUS_SUCCESS) {	    ok(unicode_string.Buffer[unicode_string.Length/sizeof(WCHAR)] == '\0',	       "(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) string \"%s\" is not NULL terminated",	       test_num, largeint2str->value, largeint2str->base, ansi_str.Buffer);	} /* if */    } /* if */    ok(memcmp(unicode_string.Buffer, expected_unicode_string.Buffer, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,       "(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) assigns string \"%s\", expected: \"%s\"",       test_num, largeint2str->value, largeint2str->base, ansi_str.Buffer, expected_ansi_str.Buffer);    ok(unicode_string.Length == expected_unicode_string.Length,       "(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) string has Length %d, expected: %d",       test_num, largeint2str->value, largeint2str->base, unicode_string.Length, expected_unicode_string.Length);    ok(unicode_string.MaximumLength == expected_unicode_string.MaximumLength,       "(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) string has MaximumLength %d, expected: %d",       test_num, largeint2str->value, largeint2str->base, unicode_string.MaximumLength, expected_unicode_string.MaximumLength);    pRtlFreeAnsiString(&expected_ansi_str);    pRtlFreeAnsiString(&ansi_str);}static void test_RtlInt64ToUnicodeString(void){    int test_num;    for (test_num = 0; test_num < NB_LARGEINT2STR; test_num++) {	one_RtlInt64ToUnicodeString_test(test_num, &largeint2str[test_num]);    } /* for */}static void one_RtlLargeIntegerToChar_test(int test_num, const largeint2str_t *largeint2str){    NTSTATUS result;    char dest_str[LARGE_STRI_BUFFER_LENGTH + 1];    ULONGLONG value;    memset(dest_str, '-', LARGE_STRI_BUFFER_LENGTH);    dest_str[LARGE_STRI_BUFFER_LENGTH] = '\0';    value = largeint2str->value;    if (largeint2str->base == 0) {	result = pRtlLargeIntegerToChar(&value, 10, largeint2str->MaximumLength, dest_str);    } else {	result = pRtlLargeIntegerToChar(&value, largeint2str->base, largeint2str->MaximumLength, dest_str);    } /* if */    ok(result == largeint2str->result,       "(test %d): RtlLargeIntegerToChar(%llu, %d, %d, [out]) has result %lx, expected: %lx",       test_num, largeint2str->value, largeint2str->base, largeint2str->MaximumLength, result, largeint2str->result);    ok(memcmp(dest_str, largeint2str->Buffer, LARGE_STRI_BUFFER_LENGTH) == 0,       "(test %d): RtlLargeIntegerToChar(%llu, %d, %d, [out]) assigns string \"%s\", expected: \"%s\"",       test_num, largeint2str->value, largeint2str->base, largeint2str->MaximumLength, dest_str, largeint2str->Buffer);}static void test_RtlLargeIntegerToChar(void){    NTSTATUS result;    int test_num;    ULONGLONG value;    for (test_num = 0; test_num < NB_LARGEINT2STR; test_num++) {	one_RtlLargeIntegerToChar_test(test_num, &largeint2str[test_num]);    } /* for */    value = largeint2str[0].value;    result = pRtlLargeIntegerToChar(&value, 20, largeint2str[0].MaximumLength, NULL);    ok(result == STATUS_INVALID_PARAMETER,       "(test a): RtlLargeIntegerToChar(%llu, %d, %d, NULL) has result %lx, expected: %x",       largeint2str[0].value, 20, largeint2str[0].MaximumLength, result, STATUS_INVALID_PARAMETER);    result = pRtlLargeIntegerToChar(&value, 20, 0, NULL);    ok(result == STATUS_INVALID_PARAMETER,       "(test b): RtlLargeIntegerToChar(%llu, %d, %d, NULL) has result %lx, expected: %x",       largeint2str[0].value, 20, largeint2str[0].MaximumLength, result, STATUS_INVALID_PARAMETER);    result = pRtlLargeIntegerToChar(&value, largeint2str[0].base, 0, NULL);    ok(result == STATUS_BUFFER_OVERFLOW,       "(test c): RtlLargeIntegerToChar(%llu, %d, %d, NULL) has result %lx, expected: %x",       largeint2str[0].value, largeint2str[0].base, 0, result, STATUS_BUFFER_OVERFLOW);    result = pRtlLargeIntegerToChar(&value, largeint2str[0].base, largeint2str[0].MaximumLength, NULL);    ok(result == STATUS_ACCESS_VIOLATION,       "(test d): RtlLargeIntegerToChar(%llu, %d, %d, NULL) has result %lx, expected: %x",       largeint2str[0].value, largeint2str[0].base, largeint2str[0].MaximumLength, result, STATUS_ACCESS_VIOLATION);}START_TEST(large_int){    InitFunctionPtrs();    test_RtlExtendedMagicDivide();    if (pRtlInt64ToUnicodeString != NULL) {	test_RtlInt64ToUnicodeString();    } /* if */    test_RtlLargeIntegerToChar();}

⌨️ 快捷键说明

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