summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-30 14:38:47 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-02 13:44:42 +0200
commitfb7a94c9594d0891d30594edaf9fdc04736aee50 (patch)
tree87962aade4a2b6a36b3bab12f79b96affff073dd /AK/Tests
parentebafc5b4d230d1b5ab8546b194af64bc615c0b48 (diff)
downloadserenity-fb7a94c9594d0891d30594edaf9fdc04736aee50.zip
AK: Add formatter for pointer types.
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/TestFormat.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/AK/Tests/TestFormat.cpp b/AK/Tests/TestFormat.cpp
index fe8c6032e0..2441303e6d 100644
--- a/AK/Tests/TestFormat.cpp
+++ b/AK/Tests/TestFormat.cpp
@@ -147,4 +147,19 @@ TEST_CASE(boolean_values)
EXPECT_EQ(String::formatted("{:#08x}", true), "0x000001");
}
+TEST_CASE(pointers)
+{
+ void* ptr = reinterpret_cast<void*>(0x4000);
+
+ if (sizeof(void*) == 4) {
+ EXPECT_EQ(String::formatted("{:p}", 32), "0x00000020");
+ EXPECT_EQ(String::formatted("{:p}", ptr), "0x00004000");
+ } else if (sizeof(void*) == 8) {
+ EXPECT_EQ(String::formatted("{:p}", 32), "0x0000000000000020");
+ EXPECT_EQ(String::formatted("{:p}", ptr), "0x0000000000004000");
+ } else {
+ ASSERT_NOT_REACHED();
+ }
+}
+
TEST_MAIN(Format)