mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Piggyback: AK: Add formatter for std::nullptr_t.
This commit is contained in:
parent
4cfef0cd95
commit
632ff01e17
Notes:
sideshowbarker
2024-07-19 00:13:43 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/632ff01e174 Pull-request: https://github.com/SerenityOS/serenity/pull/4727
2 changed files with 16 additions and 0 deletions
11
AK/Format.h
11
AK/Format.h
|
@ -348,6 +348,17 @@ struct Formatter<double> : StandardFormatter {
|
|||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct Formatter<std::nullptr_t> : Formatter<FlatPtr> {
|
||||
void format(FormatBuilder& builder, std::nullptr_t)
|
||||
{
|
||||
if (m_mode == Mode::Default)
|
||||
m_mode = Mode::Pointer;
|
||||
|
||||
return Formatter<FlatPtr>::format(builder, 0);
|
||||
}
|
||||
};
|
||||
|
||||
void vformat(StringBuilder& builder, StringView fmtstr, TypeErasedFormatParams);
|
||||
void vformat(const LogStream& stream, StringView fmtstr, TypeErasedFormatParams);
|
||||
|
||||
|
|
|
@ -269,4 +269,9 @@ TEST_CASE(yay_this_implementation_sucks)
|
|||
EXPECT_EQ(String::formatted("{:.0}", .99999999999), "0.");
|
||||
}
|
||||
|
||||
TEST_CASE(format_nullptr)
|
||||
{
|
||||
EXPECT_EQ(String::formatted("{}", nullptr), String::formatted("{:p}", static_cast<FlatPtr>(0)));
|
||||
}
|
||||
|
||||
TEST_MAIN(Format)
|
||||
|
|
Loading…
Add table
Reference in a new issue