summaryrefslogtreecommitdiffstats
path: root/googletest/src
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2025-05-30 20:58:02 (GMT)
committerCopybara-Service <copybara-worker@google.com>2025-05-30 20:58:42 (GMT)
commite9092b12dc3cf617d47578f13a1f64285cfa5b2f (patch)
tree8be4f1c931fa5d315c9bdf3974834511158e25db /googletest/src
parent7427a6b5e3e04f895ecad5c647c94629fb2acdc0 (diff)
downloadgoogletest-e9092b12dc3cf617d47578f13a1f64285cfa5b2f.zip
googletest-e9092b12dc3cf617d47578f13a1f64285cfa5b2f.tar.gz
googletest-e9092b12dc3cf617d47578f13a1f64285cfa5b2f.tar.bz2
Fix unified diff headers.
The length part (only) of each range is optional when equal to one. See http://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html PiperOrigin-RevId: 765326445 Change-Id: I4aec68e82f889e3b4f01861d3b6a16a8b2785ce6
Diffstat (limited to 'googletest/src')
-rw-r--r--googletest/src/gtest.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 09af151..6be9300 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -1488,17 +1488,17 @@ class Hunk {
// Print a unified diff header for one hunk.
// The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
- // where the left/right parts are omitted if unnecessary.
+ // where the left/right lengths are omitted if unnecessary.
void PrintHeader(std::ostream* ss) const {
- *ss << "@@ ";
- if (removes_) {
- *ss << "-" << left_start_ << "," << (removes_ + common_);
+ size_t left_length = removes_ + common_;
+ size_t right_length = adds_ + common_;
+ *ss << "@@ " << "-" << left_start_;
+ if (left_length != 1) {
+ *ss << "," << left_length;
}
- if (removes_ && adds_) {
- *ss << " ";
- }
- if (adds_) {
- *ss << "+" << right_start_ << "," << (adds_ + common_);
+ *ss << " " << "+" << right_start_;
+ if (right_length != 1) {
+ *ss << "," << right_length;
}
*ss << " @@\n";
}