summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-10-06 13:57:20 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-06 15:28:39 +0200
commitd2ca7ca017a1d5e3b524ceccf9dbbf4e826fbef5 (patch)
treea9ea213ae63da206832ffda808ea9dc331b92b05 /AK/Tests
parent7c2cd81edb5076f34bc067396412191be216f59c (diff)
downloadserenity-d2ca7ca017a1d5e3b524ceccf9dbbf4e826fbef5.zip
AK+Format: Make it possible to format string literals as pointers.
String literals are just pointers to a constant character. It should be possible to format them as such. (The default is to print them as strings still.)
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/TestFormat.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/AK/Tests/TestFormat.cpp b/AK/Tests/TestFormat.cpp
index ea7fb5db19..7df8430b5e 100644
--- a/AK/Tests/TestFormat.cpp
+++ b/AK/Tests/TestFormat.cpp
@@ -182,4 +182,10 @@ TEST_CASE(ensure_that_format_works)
}
}
+TEST_CASE(format_string_literal_as_pointer)
+{
+ const char* literal = "abc";
+ EXPECT_EQ(String::formatted("{:p}", literal), String::formatted("{:p}", reinterpret_cast<FlatPtr>(literal)));
+}
+
TEST_MAIN(Format)