Fix binary formatting for integers 2 and 3 (#1123)

This commit is contained in:
mierenhoop 2024-03-26 05:11:09 +01:00 committed by GitHub
parent 74a85087de
commit 43885a76e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -21,7 +21,7 @@
static inline int PickGoodWidth(unsigned x) {
if (x < 16) {
if (x < 2) return 0;
if (x < 2) return 1;
if (x < 8) return 7;
return 15;
} else {

View file

@ -40,13 +40,13 @@ TEST(FormatBinary64, test2) {
}
TEST(FormatBinary64, test3) {
EXPECT_EQ(3, FormatBinary64(buf, 1, 2) - buf);
EXPECT_STREQ("0b1", buf);
EXPECT_EQ(4, FormatBinary64(buf, 1, 2) - buf);
EXPECT_STREQ("0b01", buf);
}
TEST(FormatBinary64, test4) {
EXPECT_EQ(1, FormatBinary64(buf, 1, 0) - buf);
EXPECT_STREQ("1", buf);
EXPECT_EQ(2, FormatBinary64(buf, 1, 0) - buf);
EXPECT_STREQ("01", buf);
}
TEST(FormatBinary64, test5) {