from strings import String

def test_eq_for_str():
    test_str = String("this is a test string!")
    assert test_str == "this is a test string!", "__eq__ wasn't implemented correctly for `String` and `str`"

def test_strings_contains():
    test_str = String("this is a test")
    assert test_str.contains("this")
    assert not test_str.contains("release")
   
def test_strings_concat():
    test_str = String("")
    test_str += "test succesful!"
    assert test_str == "test succesful!"
    assert test_str.concat(" Or is it?") == "test succesful! Or is it?"
    
def test_strings_strip():
    test_str = String("           halo?      \n")
    test_str = test_str.strip()
    assert test_str == "halo?"
    test_str = String("    \n       ")
    test_str = test_str.strip()
    assert test_str == ""
   
   
def test_strings_replace():
    test_str = String("har har har, try replacing thhis") 
    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(" ")
    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"
    assert String(", ").join([]) == ""