diff options
| author | Damien George | 2014-03-13 21:53:36 +0000 |
|---|---|---|
| committer | Damien George | 2014-03-13 21:53:36 +0000 |
| commit | de4d7aecc8d2a47b4a07eb29047a3bf3ac021115 (patch) | |
| tree | 02c79e39de9d3433d7c796887fb9d97040bb49dc /tests | |
| parent | aae40ee6444db616a994c5827e5007fe19895f8d (diff) | |
| parent | c5d70ba48b77508cdfc2a5e08128db375cf618d2 (diff) | |
Merge pull request #343 from xbe/master
Implement str.count and add tests for it.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/basics/list_index.py | 10 | ||||
| -rw-r--r-- | tests/basics/string_count.py | 22 | ||||
| -rw-r--r-- | tests/basics/string_find.py | 12 |
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/basics/list_index.py b/tests/basics/list_index.py index f28263fba..a669e69c4 100644 --- a/tests/basics/list_index.py +++ b/tests/basics/list_index.py @@ -3,6 +3,16 @@ print(a.index(1)) print(a.index(2)) print(a.index(3)) print(a.index(3, 2)) +print(a.index(1, -100)) +print(a.index(1, False)) + +try: + print(a.index(1, True)) +except ValueError: + print("Raised ValueError") +else: + print("Did not raise ValueError") + try: print(a.index(3, 2, 2)) except ValueError: diff --git a/tests/basics/string_count.py b/tests/basics/string_count.py new file mode 100644 index 000000000..bac99e78d --- /dev/null +++ b/tests/basics/string_count.py @@ -0,0 +1,22 @@ +print("asdfasdfaaa".count("asdf", -100)) +print("asdfasdfaaa".count("asdf", -8)) +print("asdf".count('s', True)) +print("asdf".count('a', True)) +print("asdf".count('a', False)) +print("asdf".count('a', 1 == 2)) +print("hello world".count('l')) +print("hello world".count('l', 5)) +print("hello world".count('l', 3)) +print("hello world".count('z', 3, 6)) +print("aaaa".count('a')) +print("aaaa".count('a', 0, 3)) +print("aaaa".count('a', 0, 4)) +print("aaaa".count('a', 0, 5)) +print("aaaa".count('a', 1, 5)) +print("aaaa".count('a', -1, 5)) +print("abbabba".count("abba")) + +def t(): + return True + +print("0000".count('0', t())) diff --git a/tests/basics/string_find.py b/tests/basics/string_find.py index 90063228f..df65fd6e5 100644 --- a/tests/basics/string_find.py +++ b/tests/basics/string_find.py @@ -9,3 +9,15 @@ print("hello world".find("ll", 1, 2)) print("hello world".find("ll", 1, 3)) print("hello world".find("ll", 1, 4)) print("hello world".find("ll", 1, 5)) +print("hello world".find("ll", -100)) +print("0000".find('0')) +print("0000".find('0', 0)) +print("0000".find('0', 1)) +print("0000".find('0', 2)) +print("0000".find('0', 3)) +print("0000".find('0', 4)) +print("0000".find('0', 5)) +print("0000".find('-1', 3)) +print("0000".find('1', 3)) +print("0000".find('1', 4)) +print("0000".find('1', 5)) |
