Skip to content

Commit

Permalink
test: add test for split_whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Aug 7, 2023
1 parent d930260 commit 461eb83
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_2616_use_pyarrow_for_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,42 @@ def test_slice():
[],
["→δε←".encode()[1:], "ζz zζ".encode()[1:], b"abc"[1:]],
]


def test_split_whitespace():
assert ak.str.split_whitespace(string_padded, max_splits=1).tolist() == [
[["", "αβγ "], ["", " "]],
[],
[["", "→δε← "], ["", "ζz zζ "], ["", "abc "]],
]
assert ak.str.split_whitespace(
string_padded, max_splits=1, reverse=True
).tolist() == [
[[" αβγ", ""], [" ", ""]],
[],
[[" →δε←", ""], [" ζz zζ", ""], [" abc", ""]],
]
assert ak.str.split_whitespace(string_padded, max_splits=None).tolist() == [
[["", "αβγ", "", ""], ["", "", ""]],
[],
[["", "→δε←", "", ""], ["", "ζz", "zζ", "", ""], ["", "abc", "", ""]],
]

# Bytestrings
assert ak.str.split_whitespace(bytestring_padded, max_splits=1).tolist() == [
[["", "αβγ "], ["", ""]],
[],
[["", "→δε← "], ["", "ζz zζ "], ["", "abc "]],
]
assert ak.str.split_whitespace(
bytestring_padded, max_splits=1, reverse=True
).tolist() == [
[[" αβγ", ""], ["", ""]],
[],
[[" →δε←", ""], [" ζz zζ", ""], [" abc", ""]],
]
assert ak.str.split_whitespace(bytestring_padded, max_splits=None).tolist() == [
[["", "αβγ", ""], ["", ""]],
[],
[["", "→δε←", ""], ["", "ζz", "zζ", ""], ["", "abc", ""]],
]

0 comments on commit 461eb83

Please sign in to comment.