summaryrefslogtreecommitdiff
path: root/absl/strings/str_cat_test.cc
diff options
context:
space:
mode:
authorGravatar Dino Radakovic <dinor@google.com>2022-05-17 15:21:04 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-05-17 15:22:17 -0700
commite92505d8d6bf50c5d44805eb5fe73e9f56484cf4 (patch)
tree15337c58ec034ea36d84701fbda295a2fa9f7616 /absl/strings/str_cat_test.cc
parent7d3b4c86928ff7b17b3b881d42355062c23f6b44 (diff)
Use NullSafeStringView for const char* args to absl::StrCat, treating null pointers as ""
Fixes #1167 PiperOrigin-RevId: 449328725 Change-Id: I813785db77b94efa49eeeff4c93449334c380935
Diffstat (limited to 'absl/strings/str_cat_test.cc')
-rw-r--r--absl/strings/str_cat_test.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/absl/strings/str_cat_test.cc b/absl/strings/str_cat_test.cc
index f3770dc0..69df2502 100644
--- a/absl/strings/str_cat_test.cc
+++ b/absl/strings/str_cat_test.cc
@@ -210,6 +210,11 @@ TEST(StrCat, CornerCases) {
EXPECT_EQ(result, "");
}
+TEST(StrCat, NullConstCharPtr) {
+ const char* null = nullptr;
+ EXPECT_EQ(absl::StrCat("mon", null, "key"), "monkey");
+}
+
// A minimal allocator that uses malloc().
template <typename T>
struct Mallocator {