mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-16 20:41:44 +00:00
[libc][NFC] fix sprintf test on 32 bit systems
The expected number for the max ptrdiff value was expected to be exactly 4294967296 (2**32) for 32 bit systems, when it should be 4294967295 (2**32 - 1). This also adds a second test to check for this case on non-32 bit systems. Reviewed By: lntue, mikhail.ramalho Differential Revision: https://reviews.llvm.org/D156257
This commit is contained in:
parent
e882edd5f1
commit
91eb99b841
@ -122,13 +122,19 @@ TEST(LlvmLibcSPrintfTest, IntConv) {
|
||||
EXPECT_EQ(written, 20);
|
||||
ASSERT_STREQ(buff, "18446744073709551615"); // ull max
|
||||
|
||||
written = __llvm_libc::sprintf(buff, "%u", ~0);
|
||||
if (sizeof(int) == 4) {
|
||||
EXPECT_EQ(written, 10);
|
||||
ASSERT_STREQ(buff, "4294967295");
|
||||
}
|
||||
|
||||
written = __llvm_libc::sprintf(buff, "%tu", ~ptrdiff_t(0));
|
||||
if (sizeof(ptrdiff_t) == 8) {
|
||||
EXPECT_EQ(written, 20);
|
||||
ASSERT_STREQ(buff, "18446744073709551615");
|
||||
} else if (sizeof(ptrdiff_t) == 4) {
|
||||
EXPECT_EQ(written, 10);
|
||||
ASSERT_STREQ(buff, "4294967296");
|
||||
ASSERT_STREQ(buff, "4294967295");
|
||||
}
|
||||
|
||||
written = __llvm_libc::sprintf(buff, "%lld", -9223372036854775807ll - 1ll);
|
||||
|
Loading…
Reference in New Issue
Block a user