diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-11 18:29:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-10-11 18:29:21 (GMT) |
commit | 2c3b2302adb1bb00b6050afc30eacbc023379b93 (patch) | |
tree | c41e4702224848fd137a0e6043949d1fa88b3b77 /Lib/test | |
parent | 60dd7dc23c37bbb1c6ecc83a866f1a379afce443 (diff) | |
download | cpython-2c3b2302adb1bb00b6050afc30eacbc023379b93.zip cpython-2c3b2302adb1bb00b6050afc30eacbc023379b93.tar.gz cpython-2c3b2302adb1bb00b6050afc30eacbc023379b93.tar.bz2 |
Issue #13134: optimize finding single-character strings using memchr
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_unicode.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 9a5862d..f79b2f0 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -171,6 +171,15 @@ class UnicodeTest(string_tests.CommonTest, def test_find(self): string_tests.CommonTest.test_find(self) + # test implementation details of the memchr fast path + self.checkequal(100, 'a' * 100 + '\u0102', 'find', '\u0102') + self.checkequal(-1, 'a' * 100 + '\u0102', 'find', '\u0201') + self.checkequal(-1, 'a' * 100 + '\u0102', 'find', '\u0120') + self.checkequal(-1, 'a' * 100 + '\u0102', 'find', '\u0220') + self.checkequal(100, 'a' * 100 + '\U00100304', 'find', '\U00100304') + self.checkequal(-1, 'a' * 100 + '\U00100304', 'find', '\U00100204') + self.checkequal(-1, 'a' * 100 + '\U00100304', 'find', '\U00102004') + # check mixed argument types self.checkequalnofix(0, 'abcdefghiabc', 'find', 'abc') self.checkequalnofix(9, 'abcdefghiabc', 'find', 'abc', 1) self.checkequalnofix(-1, 'abcdefghiabc', 'find', 'def', 4) @@ -180,6 +189,14 @@ class UnicodeTest(string_tests.CommonTest, def test_rfind(self): string_tests.CommonTest.test_rfind(self) + # test implementation details of the memrchr fast path + self.checkequal(0, '\u0102' + 'a' * 100 , 'rfind', '\u0102') + self.checkequal(-1, '\u0102' + 'a' * 100 , 'rfind', '\u0201') + self.checkequal(-1, '\u0102' + 'a' * 100 , 'rfind', '\u0120') + self.checkequal(-1, '\u0102' + 'a' * 100 , 'rfind', '\u0220') + self.checkequal(0, '\U00100304' + 'a' * 100, 'rfind', '\U00100304') + self.checkequal(-1, '\U00100304' + 'a' * 100, 'rfind', '\U00100204') + self.checkequal(-1, '\U00100304' + 'a' * 100, 'rfind', '\U00102004') # check mixed argument types self.checkequalnofix(9, 'abcdefghiabc', 'rfind', 'abc') self.checkequalnofix(12, 'abcdefghiabc', 'rfind', '') |