This commit is contained in:
Kovid Goyal 2012-07-05 17:00:23 +05:30
parent 315722a2bd
commit 79bd4403d0

View File

@ -184,6 +184,7 @@ def primary_find(pat, src):
################################################################################ ################################################################################
def test(): # {{{ def test(): # {{{
from calibre import prints
# Data {{{ # Data {{{
german = ''' german = '''
Sonntag Sonntag
@ -277,8 +278,6 @@ pêché'''
german = create(german) german = create(german)
c = _icu.Collator('de') c = _icu.Collator('de')
gs = list(sorted(german, key=c.sort_key)) gs = list(sorted(german, key=c.sort_key))
for x in gs:
print '\t', x.encode('utf-8')
if gs != create(german_good): if gs != create(german_good):
print 'German sorting failed' print 'German sorting failed'
return return
@ -286,8 +285,6 @@ pêché'''
french = create(french) french = create(french)
c = _icu.Collator('fr') c = _icu.Collator('fr')
fs = list(sorted(french, key=c.sort_key)) fs = list(sorted(french, key=c.sort_key))
for x in fs:
print '\t', x.encode('utf-8')
if fs != create(french_good): if fs != create(french_good):
print 'French sorting failed (note that French fails with icu < 4.6)' print 'French sorting failed (note that French fails with icu < 4.6)'
return return
@ -306,10 +303,10 @@ pêché'''
for k, v in {u'pèché': u'peche', u'flüße':u'flusse', for k, v in {u'pèché': u'peche', u'flüße':u'flusse',
u'Štepánek':u'Štepanek'}.iteritems(): u'Štepánek':u'Štepanek'}.iteritems():
if primary_strcmp(k, v) != 0: if primary_strcmp(k, v) != 0:
print 'primary_strcmp() failed with %s != %s'%(k, v) prints('primary_strcmp() failed with %s != %s'%(k, v))
return return
if primary_find(v, u' '+k)[0] != 1: if primary_find(v, u' '+k)[0] != 1:
print 'primary_find() failed with %s not in %s'%(v, k) prints('primary_find() failed with %s not in %s'%(v, k))
return return
global _primary_collator global _primary_collator