Example #1
0
def test_get_lower_case_words():
    processor = StringProcessor()
    assert ['hello', 'there'] == processor.get_lower_case_words([0, 5],
                                                                "HelloThere")
    assert ['hello', 'there',
            'friends'] == processor.get_lower_case_words([0, 5, 10],
                                                         "HelloThereFriends")
def test_process_string():
    """Test for process_string function"""

    sp = StringProcessor()
    assert sp.process_string("ab") == ""
    assert sp.process_string("ab*") == "b"
    assert sp.process_string("ab^") == "ba"
    assert sp.process_string("^") == ""
def test_process_string():
    """Test for process_string function"""
    # Include the following cases
    # "ab" should yield "" as ouptut
    # "ab*" should yield "b" as output
    # "ab^" should yield "ba" as output
    # "^" should yield "" as output
    process_test = StringProcessor()
    assert process_test.process_string("ab") == ""
    assert process_test.process_string("ab*") == "b"
    assert process_test.process_string("ab^") == "ba"
    assert process_test.process_string("^") == ""
Example #4
0
def test_process_string():
    """Test for process_string function"""
    decode = StringProcessor()
    assert decode.process_string("ab") == ""
    decode.output = ""

    assert decode.process_string("ab*") == "b"
    decode.output = ""

    assert decode.process_string("ab^") == "ba"
    decode.output = ""

    assert decode.process_string("^") == ""
def test_process_string():
    """Test for process_string function"""
    # Include the following cases
    # "ab" should yield "" as ouptut
    # "ab*" should yield "b" as output
    # "ab^" should yield "ba" as output
    # "^" should yield "" as output
    sp = StringProcessor()
    assert sp.process_string("ab") == ""
    assert sp.process_string("ab*") == "b"
    assert sp.process_string("ab^") == "ba"
    assert sp.process_string("^") == ""
    assert sp.process_string("a^") == "a"
    assert sp.process_string("b-5es^m9c*u?er^xl0t*a") == "secret"
    assert sp.process_string("na0s*9-o*veXul^z-2it^,no^pr8") == "solution"
    assert sp.process_string(
        "zeM^un-e*0 t^a*l t^75*4a1:^s35*A,P ^2NM* ,^Mc.+GcO^"
        " t^3*,0^2 ^5m0*x81^") == "Meet at 5:15 PM, Oct 30, 2018"
Example #6
0
def main():
    sp = StringProcessor()
    line = input("Input a line:\n")
    print(sp.process_string(line))
def enc(s):
    return StringProcessor.enc_string(s)
def dec(s):
    return StringProcessor.dec_string(s)
Example #9
0
def test_get_upper_case_indices():
    processor = StringProcessor()
    assert [0, 5] == processor.get_upper_case_indices("HelloThere")
    assert [0, 5, 10] == processor.get_upper_case_indices("HelloThereFriends")
Example #10
0
def test_to_camel_case():
    processor = StringProcessor()
    assert 'HelloThere' == processor.to_camel_case("hello there")
    assert 'HelloThere' == processor.to_camel_case('hello_there')
Example #11
0
def test_capitalize_words():
    processor = StringProcessor()
    assert ['Hello', 'There'] == processor.capitalize_words(['hello', 'there'])
    assert ['Hello', 'There', 'Friends'
            ] == processor.capitalize_words(['hello', 'there', 'friends'])
Example #12
0
def test_split():
    processor = StringProcessor()
    assert ['hello', 'there'] == processor.split("hello_there")
    assert ['hello', 'there'] == processor.split("hello there")
    assert ['hello', 'there',
            'friends'] == processor.split("hello there friends")
Example #13
0
def test_to_snake_case():
    processor = StringProcessor()
    assert 'hello_there' == processor.to_snake_case("HelloThere")
    assert 'hello_there' == processor.to_snake_case("hello_there")
    assert 'hello_there' == processor.to_snake_case("Hello There")
Example #14
0
def test_remove_whitespace():
    processor = StringProcessor()
    assert 'HelloThere' == processor.remove_whitespace("Hello There")
    assert 'HelloThere' == processor.remove_whitespace("HelloThere")
Example #15
0
def test_connect_words():
    processor = StringProcessor()
    assert 'hello_there' == processor.connect_words(['hello', 'there'])
    assert 'hello_there_friends' == processor.connect_words(
        ['hello', 'there', 'friends'])
from string_processor import StringProcessor

string_processor = StringProcessor()
assert (hasattr(string_processor, "stack"))
assert (hasattr(string_processor, "reverse"))
assert (hasattr(string_processor, "process_sequence"))
assert (hasattr(string_processor, "binary_string"))
assert (hasattr(string_processor, "is_balanced"))

s = string_processor.reverse("abc123")
assert (s == "321cba")

s = string_processor.reverse("xyzert")
assert (s == "trezyx")

s = string_processor.process_sequence("AB**")
assert (s == "BA")

s = string_processor.process_sequence("AB*C**")
assert (s == "BCA")

s = string_processor.process_sequence("AB*C*DE*F***")
assert (s == "BCEFDA")

# Test if the stack if clean after/before process sequence
s = string_processor.process_sequence("AB*C*DE*F**")
assert (s == "BCEFD")

s = string_processor.process_sequence("AB**")
assert (s == "BA")