[libc-commits] [libc] [libc] Support C23 'b' (binary) modifier in printf (PR #80851)
via libc-commits
libc-commits at lists.llvm.org
Tue Feb 6 09:56:53 PST 2024
================
@@ -210,6 +210,20 @@ TEST_F(LlvmLibcPrintfConverterTest, HexConversion) {
ASSERT_EQ(writer.get_chars_written(), 18);
}
+TEST_F(LlvmLibcPrintfConverterTest, BinaryConversion) {
+ LIBC_NAMESPACE::printf_core::FormatSection section;
+ section.has_conv = true;
+ section.raw_string = "%b";
+ section.conv_name = 'b';
+ section.conv_val_raw = 42;
+ LIBC_NAMESPACE::printf_core::convert(&writer, section);
+
+ wb.buff[wb.buff_cur] = '\0';
+
+ ASSERT_STREQ(str, "101010");
----------------
michaelrj-google wrote:
This is fine as a start, but it's important to have complete tests.
Most of the functionality tests are in `sprintf_test.cpp`, so I'd recommend adding a set of tests there. You can use the `HexConv` tests as a base.
https://github.com/llvm/llvm-project/pull/80851
More information about the libc-commits
mailing list