diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py b/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py index de79469cfb..91d099333a 100644 --- a/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestStringEncoding.py @@ -1,44 +1,44 @@ -# -*- coding: utf-8 -*- - -import sys -import unittest - -import Cython.Compiler.StringEncoding as StringEncoding - - -class StringEncodingTest(unittest.TestCase): - """ - Test the StringEncoding module. - """ - def test_string_contains_lone_surrogates(self): - self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"abc")) - self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\uABCD")) - self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\N{SNOWMAN}")) - - # This behaves differently in Py2 when freshly parsed and read from a .pyc file, - # but it seems to be a marshalling bug in Py2, which doesn't hurt us in Cython. - if sys.version_info[0] != 2: - self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800\uDFFF")) - - # In Py2 with 16bit Unicode, the following is indistinguishable from the 32bit character. - obfuscated_surrogate_pair = (u"\uDFFF" + "\uD800")[::-1] - if sys.version_info[0] == 2 and sys.maxunicode == 65565: - self.assertFalse(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) - else: - self.assertTrue(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) - - self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800")) - self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF")) - self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF\uD800")) - self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800x\uDFFF")) - - def test_string_contains_surrogates(self): - self.assertFalse(StringEncoding.string_contains_surrogates(u"abc")) - self.assertFalse(StringEncoding.string_contains_surrogates(u"\uABCD")) - self.assertFalse(StringEncoding.string_contains_surrogates(u"\N{SNOWMAN}")) - - self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800")) - self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF")) - self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800\uDFFF")) - self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF\uD800")) - self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800x\uDFFF")) +# -*- coding: utf-8 -*- + +import sys +import unittest + +import Cython.Compiler.StringEncoding as StringEncoding + + +class StringEncodingTest(unittest.TestCase): + """ + Test the StringEncoding module. + """ + def test_string_contains_lone_surrogates(self): + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"abc")) + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\uABCD")) + self.assertFalse(StringEncoding.string_contains_lone_surrogates(u"\N{SNOWMAN}")) + + # This behaves differently in Py2 when freshly parsed and read from a .pyc file, + # but it seems to be a marshalling bug in Py2, which doesn't hurt us in Cython. + if sys.version_info[0] != 2: + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800\uDFFF")) + + # In Py2 with 16bit Unicode, the following is indistinguishable from the 32bit character. + obfuscated_surrogate_pair = (u"\uDFFF" + "\uD800")[::-1] + if sys.version_info[0] == 2 and sys.maxunicode == 65565: + self.assertFalse(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) + else: + self.assertTrue(StringEncoding.string_contains_lone_surrogates(obfuscated_surrogate_pair)) + + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uDFFF\uD800")) + self.assertTrue(StringEncoding.string_contains_lone_surrogates(u"\uD800x\uDFFF")) + + def test_string_contains_surrogates(self): + self.assertFalse(StringEncoding.string_contains_surrogates(u"abc")) + self.assertFalse(StringEncoding.string_contains_surrogates(u"\uABCD")) + self.assertFalse(StringEncoding.string_contains_surrogates(u"\N{SNOWMAN}")) + + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800\uDFFF")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uDFFF\uD800")) + self.assertTrue(StringEncoding.string_contains_surrogates(u"\uD800x\uDFFF")) |