ntdll/tests: Print 64bit integers as two 32 bit integers.

This commit is contained in:
Stefan Leichter 2006-08-23 00:16:51 +02:00 committed by Alexandre Julliard
parent 8922e20096
commit 0e592aa9bd
4 changed files with 84 additions and 60 deletions

View file

@ -113,8 +113,10 @@ static void test_RtlExtendedMagicDivide(void)
for (i = 0; i < NB_MAGIC_DIVIDE; i++) {
result = pRtlExtendedMagicDivide(magic_divide[i].a, magic_divide[i].b, magic_divide[i].shift);
ok(result == magic_divide[i].result,
"call failed: RtlExtendedMagicDivide(%lld, %llu, %d) has result %llx, expected %llx\n",
magic_divide[i].a, magic_divide[i].b, magic_divide[i].shift, result, magic_divide[i].result);
"call failed: RtlExtendedMagicDivide(0x%lx%08lx, 0x%lx%08lx, %d) has result 0x%lx%08lx, expected 0x%lx%08lx\n",
(DWORD)(magic_divide[i].a >> 32), (DWORD)magic_divide[i].a, (DWORD)(magic_divide[i].b >> 32),
(DWORD)magic_divide[i].b, magic_divide[i].shift, (DWORD)(result >> 32), (DWORD)result,
(DWORD)(magic_divide[i].result >> 32), (DWORD)magic_divide[i].result);
}
}
@ -322,23 +324,28 @@ static void one_RtlInt64ToUnicodeString_test(int test_num, const largeint2str_t
} /* if */
} else {
ok(result == largeint2str->result,
"(test %d): RtlInt64ToUnicodeString(%llu, %d, [out]) has result %lx, expected: %lx\n",
test_num, largeint2str->value, largeint2str->base, result, largeint2str->result);
"(test %d): RtlInt64ToUnicodeString(0x%lx%08lx, %d, [out]) has result %lx, expected: %lx\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)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\n",
test_num, largeint2str->value, largeint2str->base, ansi_str.Buffer);
"(test %d): RtlInt64ToUnicodeString(0x%lx%08lx, %d, [out]) string \"%s\" is not NULL terminated\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)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\"\n",
test_num, largeint2str->value, largeint2str->base, ansi_str.Buffer, expected_ansi_str.Buffer);
"(test %d): RtlInt64ToUnicodeString(0x%lx%08lx, %d, [out]) assigns string \"%s\", expected: \"%s\"\n",
test_num, (DWORD)(largeint2str->value >>32), (DWORD)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\n",
test_num, largeint2str->value, largeint2str->base, unicode_string.Length, expected_unicode_string.Length);
"(test %d): RtlInt64ToUnicodeString(0x%lx%08lx, %d, [out]) string has Length %d, expected: %d\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)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\n",
test_num, largeint2str->value, largeint2str->base, unicode_string.MaximumLength, expected_unicode_string.MaximumLength);
"(test %d): RtlInt64ToUnicodeString(0x%lx%08lx, %d, [out]) string has MaximumLength %d, expected: %d\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)largeint2str->value, largeint2str->base,
unicode_string.MaximumLength, expected_unicode_string.MaximumLength);
pRtlFreeAnsiString(&expected_ansi_str);
pRtlFreeAnsiString(&ansi_str);
}
@ -369,11 +376,13 @@ static void one_RtlLargeIntegerToChar_test(int test_num, const largeint2str_t *l
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\n",
test_num, largeint2str->value, largeint2str->base, largeint2str->MaximumLength, result, largeint2str->result);
"(test %d): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, [out]) has result %lx, expected: %lx\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)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\"\n",
test_num, largeint2str->value, largeint2str->base, largeint2str->MaximumLength, dest_str, largeint2str->Buffer);
"(test %d): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, [out]) assigns string \"%s\", expected: \"%s\"\n",
test_num, (DWORD)(largeint2str->value >> 32), (DWORD)largeint2str->value, largeint2str->base,
largeint2str->MaximumLength, dest_str, largeint2str->Buffer);
}
@ -390,23 +399,27 @@ static void test_RtlLargeIntegerToChar(void)
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: %lx\n",
largeint2str[0].value, 20, largeint2str[0].MaximumLength, result, STATUS_INVALID_PARAMETER);
"(test a): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, NULL) has result %lx, expected: %lx\n",
(DWORD)(largeint2str[0].value >> 32), (DWORD)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: %lx\n",
largeint2str[0].value, 20, largeint2str[0].MaximumLength, result, STATUS_INVALID_PARAMETER);
"(test b): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, NULL) has result %lx, expected: %lx\n",
(DWORD)(largeint2str[0].value >> 32), (DWORD)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: %lx\n",
largeint2str[0].value, largeint2str[0].base, 0, result, STATUS_BUFFER_OVERFLOW);
"(test c): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, NULL) has result %lx, expected: %lx\n",
(DWORD)(largeint2str[0].value >> 32), (DWORD)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: %lx\n",
largeint2str[0].value, largeint2str[0].base, largeint2str[0].MaximumLength, result, STATUS_ACCESS_VIOLATION);
"(test d): RtlLargeIntegerToChar(0x%lx%08lx, %d, %d, NULL) has result %lx, expected: %lx\n",
(DWORD)(largeint2str[0].value >> 32), (DWORD)largeint2str[0].value,
largeint2str[0].base, largeint2str[0].MaximumLength, result, STATUS_ACCESS_VIOLATION);
}

View file

@ -266,8 +266,8 @@ static void test_RtlUlonglongByteSwap(void)
result = pRtlUlonglongByteSwap( ((ULONGLONG)0x76543210 << 32) | 0x87654321 );
ok( (((ULONGLONG)0x21436587 << 32) | 0x10325476) == result,
"RtlUlonglongByteSwap(0x7654321087654321) returns 0x%llx, expected 0x2143658710325476\n",
result);
"RtlUlonglongByteSwap(0x7654321087654321) returns 0x%lx%08lx, expected 0x2143658710325476\n",
(DWORD)(result >> 32), (DWORD)result);
}
@ -490,11 +490,11 @@ static void test_RtlUniform(void)
seed_bak = seed;
result = pRtlUniform(&seed);
ok(result == expected,
"test: %llu RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
num, seed_bak, result, expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, expected);
ok(seed == expected,
"test: %llu RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
num, seed_bak, seed, expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, expected);
} /* for */
/*
* Further investigation shows: In the different regions the highest bit
@ -537,11 +537,11 @@ static void test_RtlUniform(void)
seed_bak = seed;
result = pRtlUniform(&seed);
ok(result == expected,
"test: %llu RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
num, seed_bak, result, expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, expected);
ok(seed == expected,
"test: %llu RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
num, seed_bak, seed, expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, expected);
} /* for */
/*
* More tests show that RtlUniform does not return 0x7ffffffd for seed values
@ -754,11 +754,11 @@ static void test_RtlRandom(void)
} /* if */
result = pRtlRandom(&seed);
ok(result == result_expected,
"test: %llu RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
num, seed_bak, result, result_expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) returns %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, result_expected);
ok(seed == seed_expected,
"test: %llu RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
num, seed_bak, seed, seed_expected);
"test: 0x%lx%08lx RtlUniform(&seed (seed == %lx)) sets seed to %lx, expected %lx\n",
(DWORD)(num >> 32), (DWORD)num, seed_bak, result, seed_expected);
} /* for */
}

View file

@ -425,13 +425,15 @@ static void test_RtlFindMostSignificantBit(void)
ulLong <<= i;
cPos = pRtlFindMostSignificantBit(ulLong);
ok (cPos == i, "didn't find MSB %llx %d %d\n", ulLong, i, cPos);
ok (cPos == i, "didn't find MSB 0x%lx%08lx %d %d\n",
(DWORD)(ulLong >> 32), (DWORD)ulLong, i, cPos);
/* Set all bits lower than bit i */
ulLong = ((ulLong - 1) << 1) | 1;
cPos = pRtlFindMostSignificantBit(ulLong);
ok (cPos == i, "didn't find MSB %llx %d %d\n", ulLong, i, cPos);
ok (cPos == i, "didn't find MSB 0x%lx%08lx %d %d\n",
(DWORD)(ulLong >> 32), (DWORD)ulLong, i, cPos);
}
cPos = pRtlFindMostSignificantBit(0);
ok (cPos == -1, "found bit when not set\n");
@ -451,12 +453,14 @@ static void test_RtlFindLeastSignificantBit(void)
ulLong = (ULONGLONG)1 << i;
cPos = pRtlFindLeastSignificantBit(ulLong);
ok (cPos == i, "didn't find LSB %llx %d %d\n", ulLong, i, cPos);
ok (cPos == i, "didn't find LSB 0x%lx%08lx %d %d\n",
(DWORD)(ulLong >> 32), (DWORD)ulLong, i, cPos);
ulLong = ~((ULONGLONG)0) << i;
cPos = pRtlFindLeastSignificantBit(ulLong);
ok (cPos == i, "didn't find LSB %llx %d %d\n", ulLong, i, cPos);
ok (cPos == i, "didn't find LSB 0x%lx%08lx %d %d\n",
(DWORD)(ulLong >> 32), (DWORD)ulLong, i, cPos);
}
cPos = pRtlFindLeastSignificantBit(0);
ok (cPos == -1, "found bit when not set\n");

View file

@ -673,8 +673,9 @@ static void one_i64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
result = p_i64tow(ulonglong2str->value, dest_wstr, ulonglong2str->base);
pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
ok(result == dest_wstr,
"(test %d): _i64tow(%llu, [out], %d) has result %p, expected: %p\n",
test_num, ulonglong2str->value, ulonglong2str->base, result, dest_wstr);
"(test %d): _i64tow(0x%lx%08lx, [out], %d) has result %p, expected: %p\n",
test_num, (DWORD)(ulonglong2str->value >> 32), (DWORD)ulonglong2str->value,
ulonglong2str->base, result, dest_wstr);
if (ulonglong2str->mask & 0x04) {
if (memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) != 0) {
for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
@ -683,14 +684,16 @@ static void one_i64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
if (memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) != 0) {
ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
"(test %d): _i64tow(%llu, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, ulonglong2str->value, ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
"(test %d): _i64tow(0x%lx%08lx, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, (DWORD)(ulonglong2str->value >> 32), (DWORD)ulonglong2str->value,
ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
} /* if */
} /* if */
} else {
ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
"(test %d): _i64tow(%llu, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, ulonglong2str->value, ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
"(test %d): _i64tow(0x%lx%08lx, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, (DWORD)(ulonglong2str->value >> 32), (DWORD)ulonglong2str->value,
ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
} /* if */
pRtlFreeAnsiString(&ansi_str);
}
@ -721,11 +724,13 @@ static void one_ui64tow_test(int test_num, const ulonglong2str_t *ulonglong2str)
result = p_ui64tow(ulonglong2str->value, dest_wstr, ulonglong2str->base);
pRtlUnicodeStringToAnsiString(&ansi_str, &unicode_string, 1);
ok(result == dest_wstr,
"(test %d): _ui64tow(%llu, [out], %d) has result %p, expected: %p\n",
test_num, ulonglong2str->value, ulonglong2str->base, result, dest_wstr);
"(test %d): _ui64tow(0x%lx%08lx, [out], %d) has result %p, expected: %p\n",
test_num, (DWORD)(ulonglong2str->value >> 32), (DWORD)ulonglong2str->value,
ulonglong2str->base, result, dest_wstr);
ok(memcmp(dest_wstr, expected_wstr, LARGE_STRI_BUFFER_LENGTH * sizeof(WCHAR)) == 0,
"(test %d): _ui64tow(%llu, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, ulonglong2str->value, ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
"(test %d): _ui64tow(0x%lx%08lx, [out], %d) assigns string \"%s\", expected: \"%s\"\n",
test_num, (DWORD)(ulonglong2str->value >> 32), (DWORD)ulonglong2str->value,
ulonglong2str->base, ansi_str.Buffer, ulonglong2str->Buffer);
pRtlFreeAnsiString(&ansi_str);
}
@ -754,8 +759,8 @@ static void test_ulonglongtow(void)
expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
result = p_i64tow(ulong2str[0].value, NULL, 10);
ok(result == NULL,
"(test d): _i64tow(%llu, NULL, 10) has result %p, expected: NULL\n",
ulonglong2str[0].value, result);
"(test d): _i64tow(0x%lx%08lx, NULL, 10) has result %p, expected: NULL\n",
(DWORD)(ulonglong2str[0].value >> 32), (DWORD)ulonglong2str[0].value, result);
if (p_ui64tow) {
for (pos = 0; pos < LARGE_STRI_BUFFER_LENGTH; pos++) {
@ -764,8 +769,8 @@ static void test_ulonglongtow(void)
expected_wstr[LARGE_STRI_BUFFER_LENGTH] = '\0';
result = p_ui64tow(ulong2str[0].value, NULL, 10);
ok(result == NULL,
"(test e): _ui64tow(%llu, NULL, 10) has result %p, expected: NULL\n",
ulonglong2str[0].value, result);
"(test e): _ui64tow(0x%lx%08lx, NULL, 10) has result %p, expected: NULL\n",
(DWORD)(ulonglong2str[0].value >> 32), (DWORD)ulonglong2str[0].value, result);
} /* if */
}
@ -1046,8 +1051,9 @@ static void test_atoi64(void)
for (test_num = 0; test_num < NB_STR2LONGLONG; test_num++) {
result = p_atoi64(str2longlong[test_num].str);
ok(result == str2longlong[test_num].value,
"(test %d): call failed: _atoi64(\"%s\") has result %lld, expected: %lld\n",
test_num, str2longlong[test_num].str, result, str2longlong[test_num].value);
"(test %d): call failed: _atoi64(\"%s\") has result 0x%lx%08lx, expected: 0x%lx%08lx\n",
test_num, str2longlong[test_num].str, (DWORD)(result >> 32), (DWORD)result,
(DWORD)(str2longlong[test_num].value >> 32), (DWORD)str2longlong[test_num].value);
} /* for */
}
@ -1062,8 +1068,9 @@ static void test_wtoi64(void)
pRtlCreateUnicodeStringFromAsciiz(&uni, str2longlong[test_num].str);
result = p_wtoi64(uni.Buffer);
ok(result == str2longlong[test_num].value,
"(test %d): call failed: _wtoi64(\"%s\") has result %lld, expected: %lld\n",
test_num, str2longlong[test_num].str, result, str2longlong[test_num].value);
"(test %d): call failed: _wtoi64(\"%s\") has result 0x%lx%08lx, expected: 0x%lx%08lx\n",
test_num, str2longlong[test_num].str, (DWORD)(result >> 32), (DWORD)result,
(DWORD)(str2longlong[test_num].value >> 32), (DWORD)str2longlong[test_num].value);
pRtlFreeUnicodeString(&uni);
} /* for */
}