Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libc/include/math.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ functions:
- type: float128
- type: float128
- type: float128
guards: LIBC_TYPES_HAS_FLOAT128
guard: LIBC_TYPES_HAS_FLOAT128
- name: ffmal
standards:
- stdc
Expand Down
20 changes: 10 additions & 10 deletions libc/include/wchar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,24 @@ functions:
- stdc
return_type: wchar_t *
arguments:
- type: __restrict wchar_t *
- type: const __restrict wchar_t *
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
- type: size_t
- name: wcsncpy
standards:
- stdc
return_type: wchar_t *
arguments:
- type: __restrict wchar_t *
- type: const __restrict wchar_t *
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
- type: size_t
- name: wcscat
standards:
- stdc
return_type: wchar_t *
arguments:
- type: __restrict wchar_t *
- type: const __restrict wchar_t *
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
- name: wcsstr
standards:
- stdc
Expand All @@ -139,13 +139,13 @@ functions:
- stdc
return_type: wchar_t *
arguments:
- type: __restrict wchar_t *
- type: const __restrict wchar_t *
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
- type: size_t
- name: wcscpy
standards:
- stdc
return_type: wchar_t *
arguments:
- type: __restrict wchar_t *
- type: const __restrict wchar_t *
- type: wchar_t *__restrict
- type: const wchar_t *__restrict
32 changes: 31 additions & 1 deletion libc/test/src/stdio/printf_core/converter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ TEST_F(LlvmLibcPrintfConverterTest, StringConversionSimple) {
TEST_F(LlvmLibcPrintfConverterTest, StringConversionPrecisionHigh) {
LIBC_NAMESPACE::printf_core::FormatSection high_precision_conv;
high_precision_conv.has_conv = true;
high_precision_conv.raw_string = "%4s";
high_precision_conv.raw_string = "%.4s";
high_precision_conv.conv_name = 's';
high_precision_conv.precision = 4;
high_precision_conv.conv_val_ptr = const_cast<char *>("456");
Expand Down Expand Up @@ -255,3 +255,33 @@ TEST_F(LlvmLibcPrintfConverterTest, OctConversion) {
ASSERT_STREQ(str, "1234");
ASSERT_EQ(writer.get_chars_written(), 4);
}

TEST_F(LlvmLibcPrintfConverterTest, FloatConversionSimple) {

LIBC_NAMESPACE::printf_core::FormatSection section;
section.has_conv = true;
section.raw_string = "%f";
section.conv_name = 'f';
section.conv_val_raw = LIBC_NAMESPACE::cpp::bit_cast<uint64_t>(1.234567);
LIBC_NAMESPACE::printf_core::convert(&writer, section);

wb.buff[wb.buff_cur] = '\0';
ASSERT_STREQ(str, "1.234567");
ASSERT_EQ(writer.get_chars_written(), 8);
}

TEST_F(LlvmLibcPrintfConverterTest, FloatConversionPrecisionHigh) {

LIBC_NAMESPACE::printf_core::FormatSection section;
section.has_conv = true;
section.raw_string = "%12.3f";
section.conv_name = 'f';
section.min_width = 12;
section.precision = 3;
section.conv_val_raw = LIBC_NAMESPACE::cpp::bit_cast<uint64_t>(0.000123);
LIBC_NAMESPACE::printf_core::convert(&writer, section);

wb.buff[wb.buff_cur] = '\0';
ASSERT_STREQ(str, " 0.000");
ASSERT_EQ(writer.get_chars_written(), 12);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having float conversion tests is useful, but currently they're all in sprintf_test.cpp because there are flags to turn float conversions on and off. There's special cmake logic to ensure that the sprintf tests also get those flags so they don't fail on targets without floats.

Loading