Skip to content

Commit

Permalink
TrimGlobalStep handles unicode characters as Ltrim and Rtrim
Browse files Browse the repository at this point in the history
  • Loading branch information
rdtr committed Jun 26, 2024
1 parent dc6e715 commit 302843b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This release also includes changes from <<release-3-6-7, 3.6.7>>.
* Deprecated `ltrim()` and `rTrim()` in favor of `l_trim()` and `r_trim` in Python.
* Fixed bug in `onCreate` for `mergeV()` where use of the `Cardinality` functions was not properly handled.
* Fixed multiple concurrent initially requests caused authentication to fail.
* Fixed so that TrimGlobalStep has the same character control handling as Ltrim and Rtrim
==== Bugs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ protected E map(final Traverser.Admin<S> traverser) {
}

// we will pass null values to next step
return null == item? null : (E) ((String) item).trim();
if (null == item)
return null;

int start = 0;
while (start < ((String) item).length() && Character.isWhitespace(((String) item).charAt(start))) {
start++;
}
int end = ((String) item).length() - 1;
while (end >= start && Character.isWhitespace(((String) item).charAt(end))) {
end--;
}
return (E) ((String) item).substring(start, end + 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: Step - lTrim()
Given the empty graph
And the traversal of
"""
g.inject(" feature", " one test", null, "", " ").lTrim()
g.inject(" feature", " one test", null, "", " ", " abc", "abc ", " abc ", "  ").lTrim()
"""
When iterated to list
Then the result should be unordered
Expand All @@ -33,6 +33,10 @@ Feature: Step - lTrim()
| null |
| str[] |
| str[] |
| str[abc] |
| str[abc ] |
| str[abc ] |
| str[] |

@GraphComputerVerificationInjectionNotSupported
Scenario: g_injectX__feature__X_lTrim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: Step - rTrim()
Given the empty graph
And the traversal of
"""
g.inject("feature ", "one test ", null, "", " ").rTrim()
g.inject("feature ", "one test ", null, "", " ", " abc", "abc ", " abc ", "  ").rTrim()
"""
When iterated to list
Then the result should be unordered
Expand All @@ -33,6 +33,10 @@ Feature: Step - rTrim()
| null |
| str[] |
| str[] |
| str[ abc] |
| str[abc] |
| str[ abc] |
| str[] |

@GraphComputerVerificationInjectionNotSupported
Scenario: g_injectX__feature__X_rTrim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: Step - trim()
Given the empty graph
And the traversal of
"""
g.inject(" feature ", " one test ", null, "", " ").trim()
g.inject(" feature ", " one test ", null, "", " ", " abc", "abc ", " abc ", "  ").trim()
"""
When iterated to list
Then the result should be unordered
Expand All @@ -33,6 +33,10 @@ Feature: Step - trim()
| null |
| str[] |
| str[] |
| str[abc] |
| str[abc] |
| str[abc] |
| str[] |

@GraphComputerVerificationInjectionNotSupported
Scenario: g_injectXListXa_bXX_trim
Expand Down

0 comments on commit 302843b

Please sign in to comment.