#!/usr/bin/env python2.7 # -*- coding: UTF-8 -*- from __future__ import print_function from __future__ import unicode_literals import re import regex import sys import os if not (("PYTHONIOENCODING" in os.environ) and re.search("^utf-?8$", os.environ["PYTHONIOENCODING"], re.I)): sys.stderr.write(sys.argv[0] + ": Please set your PYTHONIOENCODING envariable to utf8\n") sys.exit(1) import unicodedata if unicodedata.unidata_version < "6.0.0": print("WARNING: Your old UCD is out of date, expected 6.0.0 but got", unicodedata.unidata_version) wide_enough = (sys.maxunicode> 65536) if not wide_enough: print("WARNING: Narrow build detected, your Python lacks full Unicode support!!") data_rows = [ [ "\u0527", "\u0527", "\u0526", "\u0526" ], [ "\u0526", "\u0527", "\u0526", "\u0526" ], [ "πΌπ―π π¨ππ―π»", "πΌπ―π π¨ππ―π»", "ππ―π π¨ππ―π»", "πππππ‘ππ" ], [ "ππ―π π¨ππ―π»", "πΌπ―π π¨ππ―π»", "ππ―π π¨ππ―π»", "πππππ‘ππ" ], [ "πππππ‘ππ", "πΌπ―π π¨ππ―π»", "ππ―π π¨ππ―π»", "πππππ‘ππ" ], ] total, bad = 0, 0 for orig, lower_want, title_want, upper_want in data_rows: total = total + 1 lower_have = orig.lower() title_have = orig.title() upper_have = orig.upper() if lower_want != lower_have: print("FAIL test", total, "lowercase of <"+orig+"> should be <"+lower_want+"> not <"+lower_have+">") bad = bad + 1 if title_want != title_have: print("FAIL test", total, "titlecase of <"+orig+"> should be <"+title_want+"> not <"+title_have+">") bad = bad + 1 if upper_want != upper_have: print("FAIL test", total, "uppercase of <"+orig+"> should be <"+upper_want+"> not <"+upper_have+">") bad = bad + 1 print("") total = total * 3 print("failed", bad, "of", total, "tests") ######################################## # $ python2.7 casemaps.python # WARNING: Your old UCD is out of date, expected 6.0.0 but got 5.2.0 # WARNING: Narrow build detected, your Python lacks full Unicode support!! # # FAIL test 1 titlecase of <Τ§> should be <Τ¦> not <Τ§> # FAIL test 1 uppercase of <Τ§> should be <Τ¦> not <Τ§> # FAIL test 2 lowercase of <Τ¦> should be <Τ§> not <Τ¦> # FAIL test 3 titlecase of <πΌπ―π π¨ππ―π»> should be <ππ―π π¨ππ―π»> not <πΌπ―π π¨ππ―π»> # FAIL test 3 uppercase of <πΌπ―π π¨ππ―π»> should be <πππππ‘ππ> not <πΌπ―π π¨ππ―π»> # FAIL test 4 lowercase of <ππ―π π¨ππ―π»> should be <πΌπ―π π¨ππ―π»> not <ππ―π π¨ππ―π»> # FAIL test 4 uppercase of <ππ―π π¨ππ―π»> should be <πππππ‘ππ> not <ππ―π π¨ππ―π»> # FAIL test 5 lowercase of <πππππ‘ππ> should be <πΌπ―π π¨ππ―π»> not <πππππ‘ππ> # FAIL test 5 titlecase of <πππππ‘ππ> should be <ππ―π π¨ππ―π»> not <πππππ‘ππ> # # failed 9 of 15 tests ############################################################## # $ python3.2 casemaps.python # WARNING: Narrow build detected, your Python lacks full Unicode support!! # FAIL test 3 titlecase of <πΌπ―π π¨ππ―π»> should be <ππ―π π¨ππ―π»> not <πΌπ―π π¨ππ―π»> # FAIL test 3 uppercase of <πΌπ―π π¨ππ―π»> should be <πππππ‘ππ> not <πΌπ―π π¨ππ―π»> # FAIL test 4 lowercase of <ππ―π π¨ππ―π»> should be <πΌπ―π π¨ππ―π»> not <ππ―π π¨ππ―π»> # FAIL test 4 uppercase of <ππ―π π¨ππ―π»> should be <πππππ‘ππ> not <ππ―π π¨ππ―π»> # FAIL test 5 lowercase of <πππππ‘ππ> should be <πΌπ―π π¨ππ―π»> not <πππππ‘ππ> # FAIL test 5 titlecase of <πππππ‘ππ> should be <ππ―π π¨ππ―π»> not <πππππ‘ππ> # # failed 6 of 15 tests