mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
AK: printf was not accounting for plus sign with "%+d"
We have to include the plus sign in the number of characters written, otherwise sprintf() will put the null terminator too early.
This commit is contained in:
parent
eed78ffa5a
commit
e9403e2b03
2 changed files with 15 additions and 1 deletions
|
@ -242,4 +242,18 @@ TEST_CASE(builder_zero_initial_capacity)
|
|||
EXPECT_EQ(built.length(), 0u);
|
||||
}
|
||||
|
||||
TEST_CASE(sprintf)
|
||||
{
|
||||
char buf1[128];
|
||||
int ret1 = sprintf(buf1, "%+d", 12);
|
||||
EXPECT_EQ(ret1, 3);
|
||||
|
||||
char buf2[128];
|
||||
int ret2 = sprintf(buf2, "%+d", -12);
|
||||
EXPECT_EQ(ret2, 3);
|
||||
|
||||
EXPECT_EQ(String(buf1), String("+12"));
|
||||
EXPECT_EQ(String(buf2), String("-12"));
|
||||
}
|
||||
|
||||
TEST_MAIN(String)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue