From cb23a71071678e40bd93ea878624ba4102d636f1 Mon Sep 17 00:00:00 2001
From: David Li
Date: Thu, 1 Jul 2021 08:17:35 -0400
Subject: [PATCH] ARROW-13234: [C++] Put extra padding spaces on the right
---
cpp/src/arrow/compute/kernels/scalar_string.cc | 12 ++++++------
cpp/src/arrow/compute/kernels/scalar_string_test.cc | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/scalar_string.cc b/cpp/src/arrow/compute/kernels/scalar_string.cc
index 7f596f22224..ab0a490eeb3 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string.cc
@@ -2845,9 +2845,9 @@ struct AsciiPadTransform : public StringTransformBase {
int64_t left = 0;
int64_t right = 0;
if (PadLeft && PadRight) {
- // If odd number of spaces, put the extra space on the left
- right = spaces / 2;
- left = spaces - right;
+ // If odd number of spaces, put the extra space on the right
+ left = spaces / 2;
+ right = spaces - left;
} else if (PadLeft) {
left = spaces;
} else if (PadRight) {
@@ -2901,9 +2901,9 @@ struct Utf8PadTransform : public StringTransformBase {
int64_t left = 0;
int64_t right = 0;
if (PadLeft && PadRight) {
- // If odd number of spaces, put the extra space on the left
- right = spaces / 2;
- left = spaces - right;
+ // If odd number of spaces, put the extra space on the right
+ left = spaces / 2;
+ right = spaces - left;
} else if (PadLeft) {
left = spaces;
} else if (PadRight) {
diff --git a/cpp/src/arrow/compute/kernels/scalar_string_test.cc b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
index e88da14c288..67f1e02558b 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
@@ -1230,7 +1230,7 @@ TYPED_TEST(TestStringKernels, PadUTF8) {
PadOptions options{/*width=*/5, "\xe2\x80\x88"};
this->CheckUnary(
"utf8_center", R"([null, "a", "bb", "b\u00E1r", "foobar"])", this->type(),
- R"([null, "\u2008\u2008a\u2008\u2008", "\u2008\u2008bb\u2008", "\u2008b\u00E1r\u2008", "foobar"])",
+ R"([null, "\u2008\u2008a\u2008\u2008", "\u2008bb\u2008\u2008", "\u2008b\u00E1r\u2008", "foobar"])",
&options);
this->CheckUnary(
"utf8_lpad", R"([null, "a", "bb", "b\u00E1r", "foobar"])", this->type(),
@@ -1401,7 +1401,7 @@ TYPED_TEST(TestStringKernels, SliceCodeunitsNegPos) {
TYPED_TEST(TestStringKernels, PadAscii) {
PadOptions options{/*width=*/5, " "};
this->CheckUnary("ascii_center", R"([null, "a", "bb", "bar", "foobar"])", this->type(),
- R"([null, " a ", " bb ", " bar ", "foobar"])", &options);
+ R"([null, " a ", " bb ", " bar ", "foobar"])", &options);
this->CheckUnary("ascii_lpad", R"([null, "a", "bb", "bar", "foobar"])", this->type(),
R"([null, " a", " bb", " bar", "foobar"])", &options);
this->CheckUnary("ascii_rpad", R"([null, "a", "bb", "bar", "foobar"])", this->type(),