Skip to content

Commit

Permalink
Added additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yushao2 committed May 12, 2021
1 parent 29b3705 commit 9dc3d82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/functional/c/consider/consider_using_str_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def get_string(self) -> str:
get_mid = bar.get_string().split(',')[1]
get_mid = bar.get_string().split(',')[-2]

# Test with iterating over strings
list_of_strs = ["a", "b", "c", "d", "e", "f"]
for s in list_of_strs:
print(s.split(" ")[0]) # [consider-using-str-partition]
print(s.split(" ")[-1]) # [consider-using-str-partition]
print(s.split(" ")[-2])

# Test with user-defined len function
def len(x: Iterable[Any]) -> str:
return f"Hello, world! {x[2]}"
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/c/consider/consider_using_str_partition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ consider-using-str-partition:53:11::Consider using Foo.class_str.rpartition(',')
consider-using-str-partition:54:11::Consider using Foo.class_str.rpartition(',')[-1] instead
consider-using-str-partition:58:12::Consider using bar.get_string().partition(',')[0] instead
consider-using-str-partition:59:11::Consider using bar.get_string().rpartition(',')[-1] instead
consider-using-str-partition:67:10::Consider using s.partition(' ')[0] instead
consider-using-str-partition:68:10::Consider using s.rpartition(' ')[-1] instead

0 comments on commit 9dc3d82

Please sign in to comment.