strings
This commit is contained in:
@ -13,36 +13,33 @@ def test_strings_concat():
|
||||
test_str = String("")
|
||||
test_str += "test succesful!"
|
||||
assert test_str == "test succesful!"
|
||||
test_str.concat(" Or is it?")
|
||||
assert test_str == "test succesful! Or is it?"
|
||||
assert test_str.concat(" Or is it?") == "test succesful! Or is it?"
|
||||
|
||||
def test_strings_strip():
|
||||
test_str = String(" halo? \n")
|
||||
test_str.strip()
|
||||
test_str = test_str.strip()
|
||||
assert test_str == "halo?"
|
||||
test_str = String(" \n ")
|
||||
test_str.strip()
|
||||
test_str = test_str.strip()
|
||||
assert test_str == ""
|
||||
|
||||
|
||||
def test_strings_replace():
|
||||
test_str = String("har har har, try replacing thhis")
|
||||
test_str.replace('har ', 'ha')
|
||||
assert test_str == "hahahar, try replacing thhis"
|
||||
test_str.replace('r', '', 1)
|
||||
assert test_str == "hahaha, try replacing thhis"
|
||||
test_str.replace('hh', 'h')
|
||||
assert test_str == "hahaha, try replacing this"
|
||||
test_str.replace('try replacing this', "replaced")
|
||||
assert test_str == "hahaha, replaced"
|
||||
assert test_str.replace('har ', 'ha') == "hahahar, try replacing thhis"
|
||||
test_str = test_str.replace('har ', 'ha')
|
||||
assert test_str.replace('r', '', 1) == "hahaha, try replacing thhis"
|
||||
test_str = test_str.replace('r', '', 1)
|
||||
assert test_str.replace('hh', 'h') == "hahaha, try replacing this"
|
||||
test_str = test_str.replace('hh', 'h')
|
||||
assert test_str.replace('try replacing this', "replaced") == "hahaha, replaced"
|
||||
|
||||
|
||||
def test_add_pre_suf():
|
||||
test_str = String(" ")
|
||||
test_str.add_suffix("suff")
|
||||
assert test_str == " suff"
|
||||
test_str.add_prefix("pref")
|
||||
assert test_str == "pref suff"
|
||||
assert test_str.add_suffix("suff") == " suff"
|
||||
assert test_str.add_prefix("pref") == "pref "
|
||||
assert test_str.add_suffix("suff").add_prefix("pref") == "pref suff"
|
||||
|
||||
def test_join():
|
||||
assert String(", ").join([1, 2, 3, 4]) == "1, 2, 3, 4"
|
||||
|
Reference in New Issue
Block a user