mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 04:20:28 +00:00
AK+Format: Use pointer mode for pointers by default.
This commit is contained in:
parent
b9316474b7
commit
b94cb02a7f
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/b94cb02a7fe Pull-request: https://github.com/SerenityOS/serenity/pull/3705 Reviewed-by: https://github.com/awesomekling
2 changed files with 5 additions and 0 deletions
|
@ -284,6 +284,9 @@ template<typename T>
|
|||
struct Formatter<T*> : StandardFormatter {
|
||||
void format(TypeErasedFormatParams& params, FormatBuilder& builder, T* value)
|
||||
{
|
||||
if (m_mode == Mode::Default)
|
||||
m_mode = Mode::Pointer;
|
||||
|
||||
Formatter<FlatPtr> formatter { *this };
|
||||
formatter.format(params, builder, reinterpret_cast<FlatPtr>(value));
|
||||
}
|
||||
|
|
|
@ -156,9 +156,11 @@ TEST_CASE(pointers)
|
|||
if (sizeof(void*) == 4) {
|
||||
EXPECT_EQ(String::formatted("{:p}", 32), "0x00000020");
|
||||
EXPECT_EQ(String::formatted("{:p}", ptr), "0x00004000");
|
||||
EXPECT_EQ(String::formatted("{}", ptr), "0x00004000");
|
||||
} else if (sizeof(void*) == 8) {
|
||||
EXPECT_EQ(String::formatted("{:p}", 32), "0x0000000000000020");
|
||||
EXPECT_EQ(String::formatted("{:p}", ptr), "0x0000000000004000");
|
||||
EXPECT_EQ(String::formatted("{}", ptr), "0x0000000000004000");
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue