diff options
author | Abseil Team <absl-team@google.com> | 2023-08-17 07:04:14 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-08-17 07:05:33 -0700 |
commit | 65d7b6d421f780941dd585d7094f257a546e2510 (patch) | |
tree | 7751d97a393f4f6597b03d29957653b24244faed /absl/strings/str_cat_test.cc | |
parent | 9377c75bf499af0018542c17abcedf659e094a1e (diff) |
StrCat: do not use intermediate buffer when result fits in SSO.
PiperOrigin-RevId: 557811632
Change-Id: I370fa17d2fb82a1f1ca86f84529bae31b34b18e4
Diffstat (limited to 'absl/strings/str_cat_test.cc')
-rw-r--r-- | absl/strings/str_cat_test.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/absl/strings/str_cat_test.cc b/absl/strings/str_cat_test.cc index 7f52e053..66eddf0d 100644 --- a/absl/strings/str_cat_test.cc +++ b/absl/strings/str_cat_test.cc @@ -665,4 +665,20 @@ TEST(StrCat, AbslStringifyWithEnum) { EXPECT_EQ(absl::StrCat(e), "Choices"); } +template <typename Integer> +void CheckSingleArgumentIntegerLimits() { + Integer max = std::numeric_limits<Integer>::max(); + Integer min = std::numeric_limits<Integer>::min(); + + EXPECT_EQ(absl::StrCat(max), std::to_string(max)); + EXPECT_EQ(absl::StrCat(min), std::to_string(min)); +} + +TEST(StrCat, SingleArgumentLimits) { + CheckSingleArgumentIntegerLimits<int32_t>(); + CheckSingleArgumentIntegerLimits<uint32_t>(); + CheckSingleArgumentIntegerLimits<int64_t>(); + CheckSingleArgumentIntegerLimits<uint64_t>(); +} + } // namespace |