From 1610b69b719db8e547f87ba554757e3bc8d2f262 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 12 Nov 2025 11:39:00 -0500 Subject: [PATCH 1/2] impl(bigtable): add string literal constructor to Bytes --- google/cloud/bigtable/bytes.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/google/cloud/bigtable/bytes.h b/google/cloud/bigtable/bytes.h index aca790a185f6b..9a735c24ec4b8 100644 --- a/google/cloud/bigtable/bytes.h +++ b/google/cloud/bigtable/bytes.h @@ -44,6 +44,9 @@ class Bytes { /// An empty sequence. Bytes() = default; + /// Strips the null-terminator character from input bytes. + explicit Bytes(char const* bytes) : bytes_(bytes) {} + /// @name Construction from a sequence of octets. ///@{ template From 8081829f3f87bb3562ef03db86c80b92ce68a787 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 12 Nov 2025 12:11:53 -0500 Subject: [PATCH 2/2] update tests --- google/cloud/bigtable/bytes.h | 2 +- google/cloud/bigtable/bytes_test.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google/cloud/bigtable/bytes.h b/google/cloud/bigtable/bytes.h index 9a735c24ec4b8..53d91facea372 100644 --- a/google/cloud/bigtable/bytes.h +++ b/google/cloud/bigtable/bytes.h @@ -44,7 +44,7 @@ class Bytes { /// An empty sequence. Bytes() = default; - /// Strips the null-terminator character from input bytes. + /// Stops copying at the null-terminator character from input bytes. explicit Bytes(char const* bytes) : bytes_(bytes) {} /// @name Construction from a sequence of octets. diff --git a/google/cloud/bigtable/bytes_test.cc b/google/cloud/bigtable/bytes_test.cc index 8d9c562cd46c4..070c614ab2ba7 100644 --- a/google/cloud/bigtable/bytes_test.cc +++ b/google/cloud/bigtable/bytes_test.cc @@ -105,8 +105,8 @@ TEST(Bytes, OutputStream) { {Bytes(std::string("a\377B")), R"(B"a\377B")"}, {Bytes(std::string("!@#$%^&*()-.")), R"(B"!@#$%^&*()-.")"}, {Bytes(std::string(3, '\0')), R"(B"\000\000\000")"}, - {Bytes(""), R"(B"\000")"}, - {Bytes("foo"), R"(B"foo\000")"}, + {Bytes(""), R"(B"")"}, + {Bytes("foo"), R"(B"foo")"}, }; for (auto const& tc : test_cases) {