[pypy-svn] r73086 - pypy/branch/cpython-extension/pypy/rlib/test
xoraxax at codespeak.net
xoraxax at codespeak.net
Mon Mar 29 17:28:42 CEST 2010
Author: xoraxax
Date: Mon Mar 29 17:28:30 2010
New Revision: 73086
Modified:
pypy/branch/cpython-extension/pypy/rlib/test/test_rstring.py
Log:
Add tests for split/rsplit.
Modified: pypy/branch/cpython-extension/pypy/rlib/test/test_rstring.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/rlib/test/test_rstring.py (original)
+++ pypy/branch/cpython-extension/pypy/rlib/test/test_rstring.py Mon Mar 29 17:28:30 2010
@@ -1,5 +1,26 @@
-from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
+from pypy.rlib.rstring import StringBuilder, UnicodeBuilder, split, rsplit
+
+def test_split():
+ assert split("", 'x') == ['']
+ assert split("a", "a", 1) == ['', '']
+ assert split(" ", " ", 1) == ['', '']
+ assert split("aa", "a", 2) == ['', '', '']
+ assert split('a|b|c|d', '|') == ['a', 'b', 'c', 'd']
+ assert split('a|b|c|d', '|', 2) == ['a', 'b', 'c|d']
+ assert split('a//b//c//d', '//') == ['a', 'b', 'c', 'd']
+ assert split('endcase test', 'test') == ['endcase ', '']
+ raises(ValueError, split, 'abc', '')
+
+def test_rsplit():
+ assert rsplit("a", "a", 1) == ['', '']
+ assert rsplit(" ", " ", 1) == ['', '']
+ assert rsplit("aa", "a", 2) == ['', '', '']
+ assert rsplit('a|b|c|d', '|') == ['a', 'b', 'c', 'd']
+ assert rsplit('a|b|c|d', '|', 2) == ['a|b', 'c', 'd']
+ assert rsplit('a//b//c//d', '//') == ['a', 'b', 'c', 'd']
+ assert rsplit('endcase test', 'test') == ['endcase ', '']
+ raises(ValueError, rsplit, "abc", '')
def test_string_builder():
s = StringBuilder()
More information about the Pypy-commit
mailing list