|
10 | 10 | decimal_to, |
11 | 11 | hierarchy_from, |
12 | 12 | string_trimmed_after, |
| 13 | + string_trimmed_before, |
13 | 14 | ) |
14 | 15 |
|
15 | 16 |
|
@@ -50,6 +51,30 @@ def test_custom_join(): |
50 | 51 | assert custom_join(pd.Series([""])) == "" |
51 | 52 |
|
52 | 53 |
|
| 54 | +def test_string_trimmed_after(): |
| 55 | + """ |
| 56 | + GIVEN a string of words separated by a specified delimiter and a specified number of occurrences, |
| 57 | + WHEN executed by string_trimmed_after, |
| 58 | + THEN a literal string is returned comprised of the left hand part of the original string |
| 59 | + before the nth occurrence of the delimiter. |
| 60 | + """ |
| 61 | + test_string = "foo:bar:doo:day" |
| 62 | + assert string_trimmed_after(test_string, ":") == "foo:bar:doo" |
| 63 | + assert string_trimmed_after(test_string, ":", 1) == "foo" |
| 64 | + |
| 65 | + |
| 66 | +def test_string_trimmed_before(): |
| 67 | + """ |
| 68 | + GIVEN a string of words separated by a specified delimiter and a specified number of occurrences, |
| 69 | + WHEN executed by string_trimmed_before, |
| 70 | + THEN a literal string is returned comprised of the right hand part of the original string |
| 71 | + after the nth occurrence of the delimiter. |
| 72 | + """ |
| 73 | + test_string = "foo:bar:doo:day" |
| 74 | + assert string_trimmed_before(test_string, ":") == "day" |
| 75 | + assert string_trimmed_before(test_string, ":", 1) == "bar:doo:day" |
| 76 | + |
| 77 | + |
53 | 78 | def test_hierarchy_from(): |
54 | 79 | """ |
55 | 80 | GIVEN a string of words delimited by colons |
|
0 commit comments