# HG changeset patch # User Paul Boddie # Date 1481840825 -3600 # Node ID 887956f46f61d1a619570c535014d153fbf8fd15 # Parent 839fad2aab0a0de8935cda2cb85914a4f0bd7092 Added tests of new string methods. diff -r 839fad2aab0a -r 887956f46f61 tests/string.py --- a/tests/string.py Thu Dec 15 23:26:40 2016 +0100 +++ b/tests/string.py Thu Dec 15 23:27:05 2016 +0100 @@ -6,6 +6,20 @@ print s[5:] # world! print s[1:10:2] # el ol print s[10:1:-2] # drwol +print s.find("w") # 6 +print s.find("w", 7) # -1 +print s.find("w", 0, 6) # -1 +print s.index("o") # 4 + +try: + print s.index("p") # should raise an exception +except ValueError, exc: + print 's.index("p"): value is not appropriate', exc.value + +print s.startswith("Hello") # True +print s.startswith("world") # False +print s.endswith("world!") # True +print s.endswith("Hello") # False s2 = "Hello worlds!" print s2 # Hello worlds!