-
Notifications
You must be signed in to change notification settings - Fork 171
Add isalpha, istitle, and title APIs in str #2357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,52 @@ def test_str_slice(): | |
# TODO: | ||
# assert a[0:5:-1] == "" | ||
|
||
def test_str_isalpha(): | ||
a: str = "helloworld" | ||
b: str = "hj kl" | ||
c: str = "a12(){}A" | ||
d: str = " " | ||
res: bool = a.isalpha() | ||
res2: bool = b.isalpha() | ||
res3: bool = c.isalpha() | ||
res4: bool = d.isalpha() | ||
assert res == True | ||
assert res2 == False | ||
assert res3 == False | ||
assert res4 == False | ||
|
||
|
||
def test_str_title(): | ||
a: str = "hello world" | ||
b: str = "hj'kl" | ||
c: str = "hELlo wOrlD" | ||
d: str = "{Hel1o}world" | ||
res: str = a.title() | ||
res2: str = b.title() | ||
res3: str = c.title() | ||
res4: str = d.title() | ||
assert res == "Hello World" | ||
assert res2 == "Hj'Kl" | ||
Agent-Hellboy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert res3 == "Hello World" | ||
assert res4 == "{Hel1O}World" | ||
|
||
def test_str_istitle(): | ||
a: str = "Hello World" | ||
b: str = "Hj'kl" | ||
c: str = "hELlo wOrlD" | ||
d: str = " Hello" | ||
e: str = " " | ||
res: bool = a.istitle() | ||
res2: bool = b.istitle() | ||
res3: bool = c.istitle() | ||
res4: bool = d.istitle() | ||
res5: bool = e.istitle() | ||
assert res == True | ||
assert res2 == False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test for empty string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this was an edge case
|
||
assert res3 == False | ||
assert res4 == True | ||
assert res5 == False | ||
|
||
def test_str_repeat(): | ||
a: str | ||
a = "Xyz" | ||
|
@@ -88,5 +134,8 @@ def check(): | |
test_str_join_empty_str() | ||
test_str_join_empty_list() | ||
test_constant_str_subscript() | ||
test_str_title() | ||
Agent-Hellboy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test_str_istitle() | ||
test_str_isalpha() | ||
Agent-Hellboy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
check() |
Uh oh!
There was an error while loading. Please reload this page.