mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-11 19:04:29 +00:00

This has the same behavior as converting std::string_view to std::string. This is an expensive conversion, so explicit conversions are helpful for avoiding unneccessary string copies.
25 lines
793 B
C++
25 lines
793 B
C++
//===-- EventTest.cpp -----------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Utility/Event.h"
|
|
#include "lldb/Utility/StreamString.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace lldb_private;
|
|
|
|
static std::string to_string(const EventDataBytes &E) {
|
|
StreamString S;
|
|
E.Dump(&S);
|
|
return std::string(S.GetString());
|
|
}
|
|
|
|
TEST(EventTest, DumpEventDataBytes) {
|
|
EXPECT_EQ(R"("foo")", to_string(EventDataBytes("foo")));
|
|
EXPECT_EQ("01 02 03", to_string(EventDataBytes("\x01\x02\x03")));
|
|
}
|