summaryrefslogtreecommitdiff
path: root/absl/strings/cord_test.cc
diff options
context:
space:
mode:
authorGravatar Bogdan Graur <bgraur@google.com>2024-02-07 10:18:20 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2024-02-07 10:19:33 -0800
commitc7ea3209e1ca99dd5f420f694eedfae6cd1b9c79 (patch)
tree178812813c613038fe7a02f3f34005aecf90d8eb /absl/strings/cord_test.cc
parent643b48a3b4362a932c0e41afce62deb55adf825b (diff)
Stop using `std::basic_string<uint8_t>` which relies on a non-standard generic
`char_traits<>` implementation, recently removed from `libc++`. PiperOrigin-RevId: 605023824 Change-Id: Ia708c91c24625afc4504fa77e959f8ed1e025589
Diffstat (limited to 'absl/strings/cord_test.cc')
-rw-r--r--absl/strings/cord_test.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/absl/strings/cord_test.cc b/absl/strings/cord_test.cc
index 69b1a69e..cdd52463 100644
--- a/absl/strings/cord_test.cc
+++ b/absl/strings/cord_test.cc
@@ -1513,12 +1513,11 @@ TEST_P(CordTest, CompareAfterAssign) {
// comparison methods from basic_string.
static void TestCompare(const absl::Cord& c, const absl::Cord& d,
RandomEngine* rng) {
- typedef std::basic_string<uint8_t> ustring;
- ustring cs(reinterpret_cast<const uint8_t*>(std::string(c).data()), c.size());
- ustring ds(reinterpret_cast<const uint8_t*>(std::string(d).data()), d.size());
- // ustring comparison is ideal because we expect Cord comparisons to be
- // based on unsigned byte comparisons regardless of whether char is signed.
- int expected = sign(cs.compare(ds));
+ // char_traits<char>::lt is guaranteed to do an unsigned comparison:
+ // https://en.cppreference.com/w/cpp/string/char_traits/cmp. We also expect
+ // Cord comparisons to be based on unsigned byte comparisons regardless of
+ // whether char is signed.
+ int expected = sign(std::string(c).compare(std::string(d)));
EXPECT_EQ(expected, sign(c.Compare(d))) << c << ", " << d;
}