From d1771bbae0f68e2700c56aa8b97819b2acb55a7a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 25 Jul 2016 19:27:01 +0300 Subject: [PATCH] tests/unicode_subscr.py: Detailed test for subscripting unicode strings. --- tests/unicode/unicode_subscr.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/unicode/unicode_subscr.py diff --git a/tests/unicode/unicode_subscr.py b/tests/unicode/unicode_subscr.py new file mode 100644 index 0000000000..a2f434de58 --- /dev/null +++ b/tests/unicode/unicode_subscr.py @@ -0,0 +1,23 @@ +a = '¢пр' + +print(a[0], a[0:1]) +print(a[1], a[1:2]) +print(a[2], a[2:3]) +try: + print(a[3]) +except IndexError: + print("IndexError") +print(a[3:4]) + +print(a[-1]) +print(a[-2], a[-2:-1]) +print(a[-3], a[-3:-2]) +try: + print(a[-4]) +except IndexError: + print("IndexError") +print(a[-4:-3]) + +print(a[0:2]) +print(a[1:3]) +print(a[2:4])