Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cpp/src/arrow/compute/kernels/scalar_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/kernels/scalar_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down