From: Stefan Behnel Date: Sat, 26 Apr 2008 06:58:21 +0000 (+0200) Subject: more tests for source code encodings: test latin-1 and the UTF-8 default X-Git-Tag: 0.9.6.14~20^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c966ccb2e30d6a5b3b75eddc26211d56819396a3;p=cython.git more tests for source code encodings: test latin-1 and the UTF-8 default --HG-- rename : tests/run/unicodeliterals.pyx => tests/run/unicodeliteralsdefault.pyx --- diff --git a/tests/run/unicodeliteralsdefault.pyx b/tests/run/unicodeliteralsdefault.pyx new file mode 100644 index 00000000..d0928d1f --- /dev/null +++ b/tests/run/unicodeliteralsdefault.pyx @@ -0,0 +1,82 @@ +## keep two lines free to make sure PEP 263 does not apply +## + +## + +# This file is written in UTF-8, but it has no encoding declaration, +# so it just defaults to UTF-8 (PEP 3120). + +__doc__ = r""" + >>> sa + 'abc' + >>> ua + u'abc' + >>> b + u'123' + >>> c + u'S\xf8k ik' + >>> d + u'\xfc\xd6\xe4' + >>> e + u'\x03g\xf8\uf8d2S\xf8k ik' + >>> f + u'\xf8' + >>> add + u'S\xf8k ik\xfc\xd6\xe4abc' + >>> null + u'\x00' +""" + """ + >>> len(sa) + 3 + >>> len(ua) + 3 + >>> len(b) + 3 + >>> len(c) + 6 + >>> len(d) + 3 + >>> len(e) + 10 + >>> len(f) + 1 + >>> len(add) + 12 + >>> len(null) + 1 +""" + u""" + >>> sa == 'abc' + True + >>> ua == u'abc' + True + >>> b == u'123' + True + >>> c == u'Søk ik' + True + >>> d == u'üÖä' + True + >>> e == u'\x03\x67\xf8\uf8d2Søk ik' # unescaped by Cython + True + >>> e == u'\\x03\\x67\\xf8\\uf8d2Søk ik' # unescaped by Python + True + >>> f == u'\xf8' # unescaped by Cython + True + >>> f == u'\\xf8' # unescaped by Python + True + >>> add == u'Søk ik' + u'üÖä' + 'abc' + True + >>> null == u'\\x00' # unescaped by Python (required by doctest) + True +""" + +sa = 'abc' +ua = u'abc' + +b = u'123' +c = u'Søk ik' +d = u'üÖä' +e = u'\x03\x67\xf8\uf8d2Søk ik' +f = u'\xf8' + +add = u'Søk ik' + u'üÖä' + 'abc' +null = u'\x00' diff --git a/tests/run/unicodeliteralslatin1.pyx b/tests/run/unicodeliteralslatin1.pyx new file mode 100644 index 00000000..b40c9ffc --- /dev/null +++ b/tests/run/unicodeliteralslatin1.pyx @@ -0,0 +1,76 @@ +# -*- coding: latin-1 -*- + +__doc__ = r""" + >>> sa + 'abc' + >>> ua + u'abc' + >>> b + u'123' + >>> c + u'S\xf8k ik' + >>> d + u'\xfc\xd6\xe4' + >>> e + u'\x03g\xf8\uf8d2S\xf8k ik' + >>> f + u'\xf8' + >>> add + u'S\xf8k ik\xfc\xd6\xe4abc' + >>> null + u'\x00' +""" + """ + >>> len(sa) + 3 + >>> len(ua) + 3 + >>> len(b) + 3 + >>> len(c) + 6 + >>> len(d) + 3 + >>> len(e) + 10 + >>> len(f) + 1 + >>> len(add) + 12 + >>> len(null) + 1 +""" + u""" + >>> sa == 'abc' + True + >>> ua == u'abc' + True + >>> b == u'123' + True + >>> c == u'Søk ik' + True + >>> d == u'üÖä' + True + >>> e == u'\x03\x67\xf8\uf8d2Søk ik' # unescaped by Cython + True + >>> e == u'\\x03\\x67\\xf8\\uf8d2Søk ik' # unescaped by Python + True + >>> f == u'\xf8' # unescaped by Cython + True + >>> f == u'\\xf8' # unescaped by Python + True + >>> add == u'Søk ik' + u'üÖä' + 'abc' + True + >>> null == u'\\x00' # unescaped by Python (required by doctest) + True +""" + +sa = 'abc' +ua = u'abc' + +b = u'123' +c = u'Søk ik' +d = u'üÖä' +e = u'\x03\x67\xf8\uf8d2Søk ik' +f = u'\xf8' + +add = u'Søk ik' + u'üÖä' + 'abc' +null = u'\x00'