diff options
author | asynts <asynts@gmail.com> | 2020-10-06 13:57:20 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-06 15:28:39 +0200 |
commit | d2ca7ca017a1d5e3b524ceccf9dbbf4e826fbef5 (patch) | |
tree | a9ea213ae63da206832ffda808ea9dc331b92b05 /AK/Tests/TestFormat.cpp | |
parent | 7c2cd81edb5076f34bc067396412191be216f59c (diff) | |
download | serenity-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/TestFormat.cpp')
-rw-r--r-- | AK/Tests/TestFormat.cpp | 6 |
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) |