Commit c7ea3209 by Bogdan Graur Committed by Copybara-Service

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
parent 643b48a3
...@@ -1513,12 +1513,11 @@ TEST_P(CordTest, CompareAfterAssign) { ...@@ -1513,12 +1513,11 @@ TEST_P(CordTest, CompareAfterAssign) {
// comparison methods from basic_string. // comparison methods from basic_string.
static void TestCompare(const absl::Cord& c, const absl::Cord& d, static void TestCompare(const absl::Cord& c, const absl::Cord& d,
RandomEngine* rng) { RandomEngine* rng) {
typedef std::basic_string<uint8_t> ustring; // char_traits<char>::lt is guaranteed to do an unsigned comparison:
ustring cs(reinterpret_cast<const uint8_t*>(std::string(c).data()), c.size()); // https://en.cppreference.com/w/cpp/string/char_traits/cmp. We also expect
ustring ds(reinterpret_cast<const uint8_t*>(std::string(d).data()), d.size()); // Cord comparisons to be based on unsigned byte comparisons regardless of
// ustring comparison is ideal because we expect Cord comparisons to be // whether char is signed.
// based on unsigned byte comparisons regardless of whether char is signed. int expected = sign(std::string(c).compare(std::string(d)));
int expected = sign(cs.compare(ds));
EXPECT_EQ(expected, sign(c.Compare(d))) << c << ", " << d; EXPECT_EQ(expected, sign(c.Compare(d))) << c << ", " << d;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment