From 5e419f501d2a7da5aadd993e13115f52dc6823fb Mon Sep 17 00:00:00 2001 From: Riyyi Date: Wed, 3 Aug 2022 15:49:43 +0200 Subject: [PATCH] Util: Change nullptr stringification --- src/util/format/formatter.cpp | 2 +- src/util/format/formatter.h | 2 +- test/unit/testutilformat.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/format/formatter.cpp b/src/util/format/formatter.cpp index f4abebf..8536f0f 100644 --- a/src/util/format/formatter.cpp +++ b/src/util/format/formatter.cpp @@ -97,7 +97,7 @@ void Formatter::format(Builder& builder, const char* value) const { Formatter::format( builder, - value != nullptr ? std::string_view { value, strlen(value) } : "(nil)"); + value != nullptr ? std::string_view { value, strlen(value) } : "nullptr"); } // Pointer diff --git a/src/util/format/formatter.h b/src/util/format/formatter.h index 64e0088..6664a09 100644 --- a/src/util/format/formatter.h +++ b/src/util/format/formatter.h @@ -149,7 +149,7 @@ struct Formatter { void format(Builder& builder, T* value) const { value == nullptr - ? builder.putString("0x0") + ? builder.putString("nullptr") : builder.putPointer(static_cast(value)); } }; diff --git a/test/unit/testutilformat.cpp b/test/unit/testutilformat.cpp index 0a3ed4f..ddcd55a 100644 --- a/test/unit/testutilformat.cpp +++ b/test/unit/testutilformat.cpp @@ -26,7 +26,7 @@ TEST_CASE(FormatBasicTypes) EXPECT_EQ(result, ""); result = Util::format("{}", nullptr); - EXPECT_EQ(result, "(nil)"); + EXPECT_EQ(result, "nullptr"); int* number = new int(3); result = Util::format("{}", number);