Skip to content

Commit

Permalink
Replace DebugString with absl::StrCat
Browse files Browse the repository at this point in the history
DebugString is going to be deprecated.
  • Loading branch information
vitalybuka committed Jan 17, 2024
1 parent 073e685 commit 86f0d4a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/libfuzzer/libfuzzer_bin_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DEFINE_BINARY_PROTO_FUZZER(const libfuzzer_example::Msg& message) {
!std::isnan(message.optional_float()) &&
std::fabs(message.optional_float()) > 1000 &&
message.any().UnpackTo(&file) && !file.name().empty()) {
std::cerr << message.DebugString() << "\n";
std::cerr << absl::StrCat(message) << "\n";
abort();
}
}
2 changes: 1 addition & 1 deletion examples/libfuzzer/libfuzzer_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DEFINE_PROTO_FUZZER(const libfuzzer_example::Msg& message) {
!std::isnan(message.optional_float()) &&
std::fabs(message.optional_float()) > 1000 &&
message.any().UnpackTo(&file) && !file.name().empty()) {
std::cerr << message.DebugString() << "\n";
std::cerr << absl::StrCat(message) << "\n";
abort();
}
}
6 changes: 3 additions & 3 deletions src/field_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class ConstFieldInstance {
const protobuf::FieldDescriptor* descriptor() const { return descriptor_; }

std::string DebugString() const {
std::string s = descriptor_->DebugString();
if (is_repeated()) s += "[" + std::to_string(index_) + "]";
return s + " of\n" + message_->DebugString();
std::string s = absl::StrCat(*descriptor_);
if (is_repeated()) s += absl::StrCat("[", index_, "]");
return s + " of\n" + absl::StrCat(*message_);
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/mutator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ std::string Mutator::MutateUtf8String(const std::string& value,

bool Mutator::IsInitialized(const Message& message) const {
if (!keep_initialized_ || message.IsInitialized()) return true;
std::cerr << "Uninitialized: " << message.DebugString() << "\n";
std::cerr << "Uninitialized: " << absl::StrCat(message) << "\n";
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/mutator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ bool Mutate(const protobuf::Message& from, const protobuf::Message& to,
}

ADD_FAILURE() << "Failed to get from:\n"
<< from.DebugString() << "\nto:\n"
<< to.DebugString();
<< absl::StrCat(from) << "\nto:\n"
<< absl::StrCat(to);
return false;
}

Expand Down

0 comments on commit 86f0d4a

Please sign in to comment.