Adopt absl::string_view in rtc_base/string_encode.*

Bug: webrtc:13579
Change-Id: If52108d151a12bde0e8d552ce7940948c08cef3a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256812
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36424}
This commit is contained in:
Ali Tofigh
2022-03-31 10:36:48 +02:00
committed by WebRTC LUCI CQ
parent f2599a7f43
commit fd6a4d6e2a
17 changed files with 125 additions and 114 deletions

View File

@ -13,6 +13,7 @@
#include <cstdint>
#include <utility>
#include "absl/strings/string_view.h"
#include "api/array_view.h"
#include "test/gmock.h"
#include "test/gtest.h"
@ -73,6 +74,13 @@ TEST(BufferTest, TestConstructArray) {
EXPECT_EQ(0, memcmp(buf.data(), kTestData, 16));
}
TEST(BufferTest, TestStringViewConversion) {
Buffer buf(kTestData);
absl::string_view view = buf;
EXPECT_EQ(view,
absl::string_view(reinterpret_cast<const char*>(kTestData), 16u));
}
TEST(BufferTest, TestSetData) {
Buffer buf(kTestData + 4, 7);
buf.SetData(kTestData, 9);