forked from OSchip/llvm-project
[NFC] Return llvm::StringRef from StringExtractor::GetStringRef.
This patch removes the two variant of StringExtractor::GetStringRef that return (non-)const references to std::string. The non-const one was being abused to reinitialize the StringExtractor and its uses are replaced by calls to the copy asignment operator. The const variant was refactored to return an actual llvm::StringRef. llvm-svn: 369493
This commit is contained in:
parent
7483005c59
commit
d35b42f20a
|
@ -45,9 +45,7 @@ public:
|
|||
|
||||
void SkipSpaces();
|
||||
|
||||
std::string &GetStringRef() { return m_packet; }
|
||||
|
||||
const std::string &GetStringRef() const { return m_packet; }
|
||||
llvm::StringRef GetStringRef() const { return m_packet; }
|
||||
|
||||
bool Empty() { return m_packet.empty(); }
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
|
|||
|
||||
const char stop_type = response.GetChar();
|
||||
LLDB_LOGF(log, "GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__,
|
||||
response.GetStringRef().c_str());
|
||||
response.GetStringRef().data());
|
||||
|
||||
switch (stop_type) {
|
||||
case 'W':
|
||||
|
@ -214,7 +214,7 @@ GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
|
|||
LLDB_LOGF(
|
||||
log,
|
||||
"error: packet with payload \"%.*s\" got invalid response \"%s\": %s",
|
||||
int(payload.size()), payload.data(), response.GetStringRef().c_str(),
|
||||
int(payload.size()), payload.data(), response.GetStringRef().data(),
|
||||
(i == (max_response_retries - 1))
|
||||
? "using invalid response and giving up"
|
||||
: "ignoring response and waiting for another");
|
||||
|
|
|
@ -751,7 +751,6 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
|
|||
size_t content_end = content_start + content_length;
|
||||
|
||||
bool success = true;
|
||||
std::string &packet_str = packet.GetStringRef();
|
||||
if (log) {
|
||||
// If logging was just enabled and we have history, then dump out what
|
||||
// we have to the log so we get the historical context. The Dump() call
|
||||
|
@ -813,11 +812,10 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
|
|||
GDBRemoteCommunicationHistory::ePacketTypeRecv,
|
||||
total_length);
|
||||
|
||||
// Clear packet_str in case there is some existing data in it.
|
||||
packet_str.clear();
|
||||
// Copy the packet from m_bytes to packet_str expanding the run-length
|
||||
// encoding in the process. Reserve enough byte for the most common case
|
||||
// (no RLE used)
|
||||
std ::string packet_str;
|
||||
packet_str.reserve(m_bytes.length());
|
||||
for (std::string::const_iterator c = m_bytes.begin() + content_start;
|
||||
c != m_bytes.begin() + content_end; ++c) {
|
||||
|
@ -840,6 +838,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
|
|||
packet_str.push_back(*c);
|
||||
}
|
||||
}
|
||||
packet = StringExtractorGDBRemote(packet_str);
|
||||
|
||||
if (m_bytes[0] == '$' || m_bytes[0] == '%') {
|
||||
assert(checksum_idx < m_bytes.size());
|
||||
|
@ -1340,7 +1339,7 @@ void GDBRemoteCommunication::AppendBytesToCache(const uint8_t *bytes,
|
|||
|
||||
if (type == PacketType::Notify) {
|
||||
// put this packet into an event
|
||||
const char *pdata = packet.GetStringRef().c_str();
|
||||
const char *pdata = packet.GetStringRef().data();
|
||||
|
||||
// as the communication class, we are a broadcaster and the async thread
|
||||
// is tuned to listen to us
|
||||
|
|
|
@ -351,7 +351,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
|
|||
if (SendPacketAndWaitForResponse(packet.GetString(), response,
|
||||
/*send_async=*/false) ==
|
||||
PacketResult::Success) {
|
||||
const char *response_cstr = response.GetStringRef().c_str();
|
||||
const char *response_cstr = response.GetStringRef().data();
|
||||
|
||||
// Hang on to the qSupported packet, so that platforms can do custom
|
||||
// configuration of the transport before attaching/launching the process.
|
||||
|
@ -465,7 +465,7 @@ bool GDBRemoteCommunicationClient::GetVContSupported(char flavor) {
|
|||
m_supports_vCont_S = eLazyBoolNo;
|
||||
if (SendPacketAndWaitForResponse("vCont?", response, false) ==
|
||||
PacketResult::Success) {
|
||||
const char *response_cstr = response.GetStringRef().c_str();
|
||||
const char *response_cstr = response.GetStringRef().data();
|
||||
if (::strstr(response_cstr, ";c"))
|
||||
m_supports_vCont_c = eLazyBoolYes;
|
||||
|
||||
|
@ -2174,8 +2174,7 @@ uint32_t GDBRemoteCommunicationClient::FindProcesses(
|
|||
if (!DecodeProcessInfoResponse(response, process_info))
|
||||
break;
|
||||
process_infos.Append(process_info);
|
||||
response.GetStringRef().clear();
|
||||
response.SetFilePos(0);
|
||||
response = StringExtractorGDBRemote();
|
||||
} while (SendPacketAndWaitForResponse("qsProcessInfo", response, false) ==
|
||||
PacketResult::Success);
|
||||
} else {
|
||||
|
@ -3897,7 +3896,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() {
|
|||
"GDBRemoteCommunicationClient::%s(): "
|
||||
"QSupportedAsyncJSONPackets returned invalid "
|
||||
"result: %s",
|
||||
__FUNCTION__, response.GetStringRef().c_str());
|
||||
__FUNCTION__, response.GetStringRef().data());
|
||||
m_supported_async_json_packets_sp.reset();
|
||||
}
|
||||
} else {
|
||||
|
@ -3975,14 +3974,14 @@ Status GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(
|
|||
SendPacketAndWaitForResponse(stream.GetString(), response, send_async);
|
||||
if (result == PacketResult::Success) {
|
||||
// We failed if the config result comes back other than OK.
|
||||
if (strcmp(response.GetStringRef().c_str(), "OK") == 0) {
|
||||
if (strcmp(response.GetStringRef().data(), "OK") == 0) {
|
||||
// Okay!
|
||||
error.Clear();
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("configuring StructuredData feature "
|
||||
"%s failed with error %s",
|
||||
type_name.AsCString(),
|
||||
response.GetStringRef().c_str());
|
||||
response.GetStringRef().data());
|
||||
}
|
||||
} else {
|
||||
// Can we get more data here on the failure?
|
||||
|
|
|
@ -59,14 +59,13 @@ GDBRemoteCommunicationServer::GetPacketAndSendResponse(
|
|||
break;
|
||||
|
||||
case StringExtractorGDBRemote::eServerPacketType_unimplemented:
|
||||
packet_result = SendUnimplementedResponse(packet.GetStringRef().c_str());
|
||||
packet_result = SendUnimplementedResponse(packet.GetStringRef().data());
|
||||
break;
|
||||
|
||||
default:
|
||||
auto handler_it = m_packet_handlers.find(packet_type);
|
||||
if (handler_it == m_packet_handlers.end())
|
||||
packet_result =
|
||||
SendUnimplementedResponse(packet.GetStringRef().c_str());
|
||||
packet_result = SendUnimplementedResponse(packet.GetStringRef().data());
|
||||
else
|
||||
packet_result = handler_it->second(packet, error, interrupt, quit);
|
||||
break;
|
||||
|
@ -140,7 +139,7 @@ GDBRemoteCommunicationServer::SendIllFormedResponse(
|
|||
const StringExtractorGDBRemote &failed_packet, const char *message) {
|
||||
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
|
||||
LLDB_LOGF(log, "GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)",
|
||||
__FUNCTION__, failed_packet.GetStringRef().c_str(),
|
||||
__FUNCTION__, failed_packet.GetStringRef().data(),
|
||||
message ? message : "");
|
||||
return SendErrorResponse(0x03);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ Status GDBRemoteCommunicationServerLLGS::LaunchProcess() {
|
|||
|
||||
if (should_forward_stdio) {
|
||||
// Temporarily relax the following for Windows until we can take advantage
|
||||
// of the recently added pty support. This doesn't really affect the use of
|
||||
// of the recently added pty support. This doesn't really affect the use of
|
||||
// lldb-server on Windows.
|
||||
#if !defined(_WIN32)
|
||||
if (llvm::Error Err = m_process_launch_info.SetUpPtyRedirection())
|
||||
|
@ -1377,7 +1377,7 @@ GDBRemoteCommunicationServerLLGS::Handle_C(StringExtractorGDBRemote &packet) {
|
|||
if (packet.GetBytesLeft() > 0) {
|
||||
// FIXME add continue at address support for $C{signo}[;{continue-address}].
|
||||
if (*packet.Peek() == ';')
|
||||
return SendUnimplementedResponse(packet.GetStringRef().c_str());
|
||||
return SendUnimplementedResponse(packet.GetStringRef().data());
|
||||
else
|
||||
return SendIllFormedResponse(
|
||||
packet, "unexpected content after $C{signal-number}");
|
||||
|
@ -1440,7 +1440,7 @@ GDBRemoteCommunicationServerLLGS::Handle_c(StringExtractorGDBRemote &packet) {
|
|||
if (has_continue_address) {
|
||||
LLDB_LOG(log, "not implemented for c[address] variant [{0} remains]",
|
||||
packet.Peek());
|
||||
return SendUnimplementedResponse(packet.GetStringRef().c_str());
|
||||
return SendUnimplementedResponse(packet.GetStringRef().data());
|
||||
}
|
||||
|
||||
// Ensure we have a native process.
|
||||
|
@ -1960,7 +1960,7 @@ GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) {
|
|||
LLDB_LOGF(log,
|
||||
"GDBRemoteCommunicationServerLLGS::%s failed, could not "
|
||||
"parse register number from request \"%s\"",
|
||||
__FUNCTION__, packet.GetStringRef().c_str());
|
||||
__FUNCTION__, packet.GetStringRef().data());
|
||||
return SendErrorResponse(0x15);
|
||||
}
|
||||
|
||||
|
@ -2040,7 +2040,7 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
|
|||
LLDB_LOGF(log,
|
||||
"GDBRemoteCommunicationServerLLGS::%s failed, could not "
|
||||
"parse register number from request \"%s\"",
|
||||
__FUNCTION__, packet.GetStringRef().c_str());
|
||||
__FUNCTION__, packet.GetStringRef().data());
|
||||
return SendErrorResponse(0x29);
|
||||
}
|
||||
|
||||
|
@ -3060,7 +3060,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qThreadStopInfo(
|
|||
LLDB_LOGF(log,
|
||||
"GDBRemoteCommunicationServerLLGS::%s failed, could not "
|
||||
"parse thread id from request \"%s\"",
|
||||
__FUNCTION__, packet.GetStringRef().c_str());
|
||||
__FUNCTION__, packet.GetStringRef().data());
|
||||
return SendErrorResponse(0x15);
|
||||
}
|
||||
return SendStopReplyPacketForThread(tid);
|
||||
|
@ -3234,7 +3234,7 @@ NativeThreadProtocol *GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix(
|
|||
"GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
|
||||
"error: expected ';' prior to start of thread suffix: packet "
|
||||
"contents = '%s'",
|
||||
__FUNCTION__, packet.GetStringRef().c_str());
|
||||
__FUNCTION__, packet.GetStringRef().data());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -3247,7 +3247,7 @@ NativeThreadProtocol *GDBRemoteCommunicationServerLLGS::GetThreadFromSuffix(
|
|||
"GDBRemoteCommunicationServerLLGS::%s gdb-remote parse "
|
||||
"error: expected 'thread:' but not found, packet contents = "
|
||||
"'%s'",
|
||||
__FUNCTION__, packet.GetStringRef().c_str());
|
||||
__FUNCTION__, packet.GetStringRef().data());
|
||||
return nullptr;
|
||||
}
|
||||
packet.SetFilePos(packet.GetFilePos() + strlen("thread:"));
|
||||
|
|
|
@ -1828,8 +1828,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
|
|||
}
|
||||
|
||||
for (const auto &pair : expedited_register_map) {
|
||||
StringExtractor reg_value_extractor;
|
||||
reg_value_extractor.GetStringRef() = pair.second;
|
||||
StringExtractor reg_value_extractor(pair.second);
|
||||
DataBufferSP buffer_sp(new DataBufferHeap(
|
||||
reg_value_extractor.GetStringRef().size() / 2, 0));
|
||||
reg_value_extractor.GetHexBytes(buffer_sp->GetData(), '\xcc');
|
||||
|
@ -2646,7 +2645,7 @@ Status ProcessGDBRemote::DoDestroy() {
|
|||
LLDB_LOGF(log,
|
||||
"ProcessGDBRemote::DoDestroy - got unexpected response "
|
||||
"to k packet: %s",
|
||||
response.GetStringRef().c_str());
|
||||
response.GetStringRef().data());
|
||||
exit_string.assign("got unexpected response to k packet: ");
|
||||
exit_string.append(response.GetStringRef());
|
||||
}
|
||||
|
@ -2808,7 +2807,7 @@ size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size,
|
|||
else
|
||||
error.SetErrorStringWithFormat(
|
||||
"unexpected response to GDB server memory read packet '%s': '%s'",
|
||||
packet, response.GetStringRef().c_str());
|
||||
packet, response.GetStringRef().data());
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("failed to send packet: '%s'", packet);
|
||||
}
|
||||
|
@ -2918,7 +2917,7 @@ Status ProcessGDBRemote::FlashErase(lldb::addr_t addr, size_t size) {
|
|||
else
|
||||
status.SetErrorStringWithFormat(
|
||||
"unexpected response to GDB server flash erase packet '%s': '%s'",
|
||||
packet.GetData(), response.GetStringRef().c_str());
|
||||
packet.GetData(), response.GetStringRef().data());
|
||||
}
|
||||
} else {
|
||||
status.SetErrorStringWithFormat("failed to send packet: '%s'",
|
||||
|
@ -2946,7 +2945,7 @@ Status ProcessGDBRemote::FlashDone() {
|
|||
else
|
||||
status.SetErrorStringWithFormat(
|
||||
"unexpected response to GDB server flash done packet: '%s'",
|
||||
response.GetStringRef().c_str());
|
||||
response.GetStringRef().data());
|
||||
}
|
||||
} else {
|
||||
status.SetErrorStringWithFormat("failed to send flash done packet");
|
||||
|
@ -3009,7 +3008,7 @@ size_t ProcessGDBRemote::DoWriteMemory(addr_t addr, const void *buf,
|
|||
else
|
||||
error.SetErrorStringWithFormat(
|
||||
"unexpected response to GDB server memory write packet '%s': '%s'",
|
||||
packet.GetData(), response.GetStringRef().c_str());
|
||||
packet.GetData(), response.GetStringRef().data());
|
||||
} else {
|
||||
error.SetErrorStringWithFormat("failed to send packet: '%s'",
|
||||
packet.GetData());
|
||||
|
@ -4452,14 +4451,13 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
|
|||
} else if (name == "invalidate_regnums") {
|
||||
SplitCommaSeparatedRegisterNumberString(value, invalidate_regs, 0);
|
||||
} else if (name == "dynamic_size_dwarf_expr_bytes") {
|
||||
StringExtractor opcode_extractor;
|
||||
std::string opcode_string = value.str();
|
||||
size_t dwarf_opcode_len = opcode_string.length() / 2;
|
||||
assert(dwarf_opcode_len > 0);
|
||||
|
||||
dwarf_opcode_bytes.resize(dwarf_opcode_len);
|
||||
reg_info.dynamic_size_dwarf_len = dwarf_opcode_len;
|
||||
opcode_extractor.GetStringRef().swap(opcode_string);
|
||||
StringExtractor opcode_extractor(opcode_string);
|
||||
uint32_t ret_val =
|
||||
opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
|
||||
assert(dwarf_opcode_len == ret_val);
|
||||
|
@ -5327,7 +5325,7 @@ public:
|
|||
result.SetStatus(eReturnStatusSuccessFinishResult);
|
||||
Stream &output_strm = result.GetOutputStream();
|
||||
output_strm.Printf(" packet: %s\n", packet_cstr);
|
||||
std::string &response_str = response.GetStringRef();
|
||||
std::string response_str = response.GetStringRef();
|
||||
|
||||
if (strstr(packet_cstr, "qGetProfileData") != nullptr) {
|
||||
response_str = process->HarmonizeThreadIdsForProfileData(response);
|
||||
|
@ -5336,7 +5334,7 @@ public:
|
|||
if (response_str.empty())
|
||||
output_strm.PutCString("response: \nerror: UNIMPLEMENTED\n");
|
||||
else
|
||||
output_strm.Printf("response: %s\n", response.GetStringRef().c_str());
|
||||
output_strm.Printf("response: %s\n", response.GetStringRef().data());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -5385,7 +5383,7 @@ public:
|
|||
if (response_str.empty())
|
||||
output_strm.PutCString("response: \nerror: UNIMPLEMENTED\n");
|
||||
else
|
||||
output_strm.Printf("response: %s\n", response.GetStringRef().c_str());
|
||||
output_strm.Printf("response: %s\n", response.GetStringRef().data());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ public:
|
|||
|
||||
void SkipSpaces();
|
||||
|
||||
std::string &GetStringRef() { return m_packet; }
|
||||
|
||||
const std::string &GetStringRef() const { return m_packet; }
|
||||
|
||||
bool Empty() { return m_packet.empty(); }
|
||||
|
|
|
@ -5,34 +5,34 @@
|
|||
|
||||
namespace {
|
||||
class StringExtractorTest : public ::testing::Test {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TEST_F(StringExtractorTest, InitEmpty) {
|
||||
const char kEmptyString[] = "";
|
||||
llvm::StringRef kEmptyString = "";
|
||||
StringExtractor ex(kEmptyString);
|
||||
|
||||
ASSERT_EQ(true, ex.IsGood());
|
||||
ASSERT_EQ(0u, ex.GetFilePos());
|
||||
ASSERT_STREQ(kEmptyString, ex.GetStringRef().c_str());
|
||||
ASSERT_EQ(kEmptyString, ex.GetStringRef());
|
||||
ASSERT_EQ(true, ex.Empty());
|
||||
ASSERT_EQ(0u, ex.GetBytesLeft());
|
||||
ASSERT_EQ(nullptr, ex.Peek());
|
||||
}
|
||||
|
||||
TEST_F(StringExtractorTest, InitMisc) {
|
||||
const char kInitMiscString[] = "Hello, StringExtractor!";
|
||||
llvm::StringRef kInitMiscString = "Hello, StringExtractor!";
|
||||
StringExtractor ex(kInitMiscString);
|
||||
|
||||
ASSERT_EQ(true, ex.IsGood());
|
||||
ASSERT_EQ(0u, ex.GetFilePos());
|
||||
ASSERT_STREQ(kInitMiscString, ex.GetStringRef().c_str());
|
||||
ASSERT_EQ(kInitMiscString, ex.GetStringRef());
|
||||
ASSERT_EQ(false, ex.Empty());
|
||||
ASSERT_EQ(sizeof(kInitMiscString) - 1, ex.GetBytesLeft());
|
||||
ASSERT_EQ(kInitMiscString.size(), ex.GetBytesLeft());
|
||||
ASSERT_EQ(kInitMiscString[0], *ex.Peek());
|
||||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_Underflow) {
|
||||
const char kEmptyString[] = "";
|
||||
llvm::StringRef kEmptyString = "";
|
||||
StringExtractor ex(kEmptyString);
|
||||
|
||||
ASSERT_EQ(-1, ex.DecodeHexU8());
|
||||
|
@ -44,8 +44,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_Underflow) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_Underflow2) {
|
||||
const char kEmptyString[] = "1";
|
||||
StringExtractor ex(kEmptyString);
|
||||
StringExtractor ex("1");
|
||||
|
||||
ASSERT_EQ(-1, ex.DecodeHexU8());
|
||||
ASSERT_EQ(true, ex.IsGood());
|
||||
|
@ -55,7 +54,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_Underflow2) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_InvalidHex) {
|
||||
const char kInvalidHex[] = "xa";
|
||||
llvm::StringRef kInvalidHex = "xa";
|
||||
StringExtractor ex(kInvalidHex);
|
||||
|
||||
ASSERT_EQ(-1, ex.DecodeHexU8());
|
||||
|
@ -66,7 +65,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_InvalidHex) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_InvalidHex2) {
|
||||
const char kInvalidHex[] = "ax";
|
||||
llvm::StringRef kInvalidHex = "ax";
|
||||
StringExtractor ex(kInvalidHex);
|
||||
|
||||
ASSERT_EQ(-1, ex.DecodeHexU8());
|
||||
|
@ -77,7 +76,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_InvalidHex2) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_Exact) {
|
||||
const char kValidHexPair[] = "12";
|
||||
llvm::StringRef kValidHexPair = "12";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
|
||||
ASSERT_EQ(0x12, ex.DecodeHexU8());
|
||||
|
@ -88,7 +87,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_Exact) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, DecodeHexU8_Extra) {
|
||||
const char kValidHexPair[] = "1234";
|
||||
llvm::StringRef kValidHexPair = "1234";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
|
||||
ASSERT_EQ(0x12, ex.DecodeHexU8());
|
||||
|
@ -99,7 +98,7 @@ TEST_F(StringExtractorTest, DecodeHexU8_Extra) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Underflow) {
|
||||
const char kEmptyString[] = "";
|
||||
llvm::StringRef kEmptyString = "";
|
||||
StringExtractor ex(kEmptyString);
|
||||
|
||||
ASSERT_EQ(0xab, ex.GetHexU8(0xab));
|
||||
|
@ -111,7 +110,7 @@ TEST_F(StringExtractorTest, GetHexU8_Underflow) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Underflow2) {
|
||||
const char kOneNibble[] = "1";
|
||||
llvm::StringRef kOneNibble = "1";
|
||||
StringExtractor ex(kOneNibble);
|
||||
|
||||
ASSERT_EQ(0xbc, ex.GetHexU8(0xbc));
|
||||
|
@ -122,7 +121,7 @@ TEST_F(StringExtractorTest, GetHexU8_Underflow2) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_InvalidHex) {
|
||||
const char kInvalidHex[] = "xx";
|
||||
llvm::StringRef kInvalidHex = "xx";
|
||||
StringExtractor ex(kInvalidHex);
|
||||
|
||||
ASSERT_EQ(0xcd, ex.GetHexU8(0xcd));
|
||||
|
@ -133,7 +132,7 @@ TEST_F(StringExtractorTest, GetHexU8_InvalidHex) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Exact) {
|
||||
const char kValidHexPair[] = "12";
|
||||
llvm::StringRef kValidHexPair = "12";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
|
||||
ASSERT_EQ(0x12, ex.GetHexU8(0x12));
|
||||
|
@ -144,7 +143,7 @@ TEST_F(StringExtractorTest, GetHexU8_Exact) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Extra) {
|
||||
const char kValidHexPair[] = "1234";
|
||||
llvm::StringRef kValidHexPair = "1234";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
|
||||
ASSERT_EQ(0x12, ex.GetHexU8(0x12));
|
||||
|
@ -155,7 +154,7 @@ TEST_F(StringExtractorTest, GetHexU8_Extra) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Underflow_NoEof) {
|
||||
const char kEmptyString[] = "";
|
||||
llvm::StringRef kEmptyString = "";
|
||||
StringExtractor ex(kEmptyString);
|
||||
const bool kSetEofOnFail = false;
|
||||
|
||||
|
@ -169,7 +168,7 @@ TEST_F(StringExtractorTest, GetHexU8_Underflow_NoEof) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Underflow2_NoEof) {
|
||||
const char kOneNibble[] = "1";
|
||||
llvm::StringRef kOneNibble = "1";
|
||||
StringExtractor ex(kOneNibble);
|
||||
const bool kSetEofOnFail = false;
|
||||
|
||||
|
@ -181,7 +180,7 @@ TEST_F(StringExtractorTest, GetHexU8_Underflow2_NoEof) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_InvalidHex_NoEof) {
|
||||
const char kInvalidHex[] = "xx";
|
||||
llvm::StringRef kInvalidHex = "xx";
|
||||
StringExtractor ex(kInvalidHex);
|
||||
const bool kSetEofOnFail = false;
|
||||
|
||||
|
@ -193,7 +192,7 @@ TEST_F(StringExtractorTest, GetHexU8_InvalidHex_NoEof) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Exact_NoEof) {
|
||||
const char kValidHexPair[] = "12";
|
||||
llvm::StringRef kValidHexPair = "12";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
const bool kSetEofOnFail = false;
|
||||
|
||||
|
@ -205,7 +204,7 @@ TEST_F(StringExtractorTest, GetHexU8_Exact_NoEof) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexU8_Extra_NoEof) {
|
||||
const char kValidHexPair[] = "1234";
|
||||
llvm::StringRef kValidHexPair = "1234";
|
||||
StringExtractor ex(kValidHexPair);
|
||||
const bool kSetEofOnFail = false;
|
||||
|
||||
|
@ -217,7 +216,7 @@ TEST_F(StringExtractorTest, GetHexU8_Extra_NoEof) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -240,7 +239,7 @@ TEST_F(StringExtractorTest, GetHexBytes) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes_FullString) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -257,7 +256,7 @@ TEST_F(StringExtractorTest, GetHexBytes_FullString) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes_OddPair) {
|
||||
const char kHexEncodedBytes[] = "abcdef012345678w";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef012345678w";
|
||||
const size_t kValidHexPairs = 7;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -276,7 +275,7 @@ TEST_F(StringExtractorTest, GetHexBytes_OddPair) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes_OddPair2) {
|
||||
const char kHexEncodedBytes[] = "abcdef012345678";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef012345678";
|
||||
const size_t kValidHexPairs = 7;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -294,7 +293,7 @@ TEST_F(StringExtractorTest, GetHexBytes_OddPair2) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes_Underflow) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -322,7 +321,7 @@ TEST_F(StringExtractorTest, GetHexBytes_Underflow) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytes_Partial) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kReadBytes = 4;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -353,7 +352,7 @@ TEST_F(StringExtractorTest, GetHexBytes_Partial) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -376,7 +375,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail_FullString) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -393,7 +392,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail_FullString) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail_OddPair) {
|
||||
const char kHexEncodedBytes[] = "abcdef012345678w";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef012345678w";
|
||||
const size_t kValidHexPairs = 7;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -409,7 +408,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail_OddPair) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail_OddPair2) {
|
||||
const char kHexEncodedBytes[] = "abcdef012345678";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef012345678";
|
||||
const size_t kValidHexPairs = 7;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -425,7 +424,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail_OddPair2) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail_Underflow) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kValidHexPairs = 8;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -454,7 +453,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail_Underflow) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetHexBytesAvail_Partial) {
|
||||
const char kHexEncodedBytes[] = "abcdef0123456789xyzw";
|
||||
llvm::StringRef kHexEncodedBytes = "abcdef0123456789xyzw";
|
||||
const size_t kReadBytes = 4;
|
||||
StringExtractor ex(kHexEncodedBytes);
|
||||
|
||||
|
@ -484,7 +483,7 @@ TEST_F(StringExtractorTest, GetHexBytesAvail_Partial) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetNameColonValueSuccess) {
|
||||
const char kNameColonPairs[] = "key1:value1;key2:value2;";
|
||||
llvm::StringRef kNameColonPairs = "key1:value1;key2:value2;";
|
||||
StringExtractor ex(kNameColonPairs);
|
||||
|
||||
llvm::StringRef name;
|
||||
|
@ -499,7 +498,7 @@ TEST_F(StringExtractorTest, GetNameColonValueSuccess) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetNameColonValueContainsColon) {
|
||||
const char kNameColonPairs[] = "key1:value1:value2;key2:value3;";
|
||||
llvm::StringRef kNameColonPairs = "key1:value1:value2;key2:value3;";
|
||||
StringExtractor ex(kNameColonPairs);
|
||||
|
||||
llvm::StringRef name;
|
||||
|
@ -514,7 +513,7 @@ TEST_F(StringExtractorTest, GetNameColonValueContainsColon) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetNameColonValueNoSemicolon) {
|
||||
const char kNameColonPairs[] = "key1:value1";
|
||||
llvm::StringRef kNameColonPairs = "key1:value1";
|
||||
StringExtractor ex(kNameColonPairs);
|
||||
|
||||
llvm::StringRef name;
|
||||
|
@ -524,7 +523,7 @@ TEST_F(StringExtractorTest, GetNameColonValueNoSemicolon) {
|
|||
}
|
||||
|
||||
TEST_F(StringExtractorTest, GetNameColonValueNoColon) {
|
||||
const char kNameColonPairs[] = "key1value1;";
|
||||
llvm::StringRef kNameColonPairs = "key1value1;";
|
||||
StringExtractor ex(kNameColonPairs);
|
||||
|
||||
llvm::StringRef name;
|
||||
|
|
Loading…
Reference in New Issue