def test_ord(): assert runicode.ORD('a') == 97 assert runicode.ORD(u'a') == 97 assert runicode.ORD(u'\uffff') == 0xffff if runicode.MAXUNICODE > 0xffff: if sys.maxunicode < 0x10000: assert runicode.ORD(u'\ud800\udc00') == 0x10000 else: assert runicode.ORD(u'\U00010000') == 0x10000 else: py.test.raises(TypeError, runicode.ORD, u'\ud800\udc00') py.test.raises(TypeError, runicode.ORD, 'abc')
def f(x): u = runicode.UNICHR(x) t = runicode.ORD(u) return t