RegressionTests__CharacterTests.st
changeset 1839 4efdf4dde1c1
parent 1447 2351db93aa5b
child 1856 323bfc068eb4
equal deleted inserted replaced
1838:152bdbf36c77 1839:4efdf4dde1c1
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'stx:goodies/regression' }"
     3 "{ Package: 'stx:goodies/regression' }"
     2 
     4 
     3 "{ NameSpace: RegressionTests }"
     5 "{ NameSpace: RegressionTests }"
     4 
     6 
     5 TestCase subclass:#CharacterTests
     7 TestCase subclass:#CharacterTests
    15 test01_CaseTesting
    17 test01_CaseTesting
    16     "test lower/uppercase return value for all unicode characters up to 16r1C6FF (i.e. Unicode 3.2)"
    18     "test lower/uppercase return value for all unicode characters up to 16r1C6FF (i.e. Unicode 3.2)"
    17 
    19 
    18     |unicodeDataFile|
    20     |unicodeDataFile|
    19 
    21 
    20     unicodeDataFile := self class packageDirectory / 'testData/UnicodeData-4.0.0.txt'.
    22     unicodeDataFile := Helper packageDirectoryForRegressionTests / 'testData/UnicodeData-4.0.0.txt'.
    21     "/ unicodeDataFile := '/Users/cg/work/exept/regression/testData/UnicodeData-4.0.0.txt' asFilename .
    23     "/ unicodeDataFile := '/Users/cg/work/exept/regression/testData/UnicodeData-4.0.0.txt' asFilename .
    22 
    24 
    23     CharacterEncoderCodeGenerator isNil ifTrue:[
    25     CharacterEncoderCodeGenerator isNil ifTrue:[
    24 	Smalltalk fileInClass:'CharacterEncoderCodeGenerator' package:'stx:goodies'
    26         Smalltalk fileInClass:'CharacterEncoderCodeGenerator' package:'stx:goodies'
    25     ].
    27     ].
    26 
    28 
    27     CharacterEncoderCodeGenerator new
    29     CharacterEncoderCodeGenerator new
    28 	readingUnicodeDataFrom:(unicodeDataFile readStream)
    30         readingUnicodeDataFrom:(unicodeDataFile readStream)
    29 	do:[:codePoint :name :category :canOrd :bidiCat :decMap
    31         do:[:codePoint :name :category :canOrd :bidiCat :decMap
    30 	    :decDigitValue :digitValue :numValue
    32             :decDigitValue :digitValue :numValue
    31 	    :mirrored :unicodeName :comment :ucValue :lcValue :tcValue |
    33             :mirrored :unicodeName :comment :ucValue :lcValue :tcValue |
    32 		|ch ucCh lcCh tcCh isUppercase isLowercase isTitlecase isLetter dToUc dToLc|
    34                 |ch ucCh lcCh tcCh isUppercase isLowercase isTitlecase isLetter dToUc dToLc|
    33 
    35 
    34 		"/ for now, do not check above 1C6FF (i.e. only Uniode 3.2)
    36                 "/ for now, do not check above 1C6FF (i.e. only Uniode 3.2)
    35 		codePoint <= 16r1C6FF ifTrue:[
    37                 codePoint <= 16r1C6FF ifTrue:[
    36 		    isUppercase := category = 'Lu'.
    38                     isUppercase := category = 'Lu'.
    37 		    isLowercase := category = 'Ll'.
    39                     isLowercase := category = 'Ll'.
    38 		    isTitlecase := category = 'Lt'.
    40                     isTitlecase := category = 'Lt'.
    39 		    isLetter := isUppercase | isLowercase | isTitlecase
    41                     isLetter := isUppercase | isLowercase | isTitlecase
    40 				or:[(category = 'Lm') or:[(category = 'Lo')]].
    42                                 or:[(category = 'Lm') or:[(category = 'Lo')]].
    41 
    43 
    42 		    ch := Character value:codePoint.
    44                     ch := Character value:codePoint.
    43 		    self assert:(ch isUppercase == isUppercase) description:('isUppercase of ',ch codePoint asString).
    45                     self assert:(ch isUppercase == isUppercase) description:('isUppercase of ',ch codePoint asString).
    44 		    self assert:(ch isLowercase == isLowercase) description:('isLowercase of ',ch codePoint asString).
    46                     self assert:(ch isLowercase == isLowercase) description:('isLowercase of ',ch codePoint asString).
    45 		    "/ self assert:(ch isTitlecase == isTitlecase).
    47                     "/ self assert:(ch isTitlecase == isTitlecase).
    46 		    self assert:(ch isNationalLetter == isLetter) description:('isNationalLetter of ',ch codePoint asString).
    48                     self assert:(ch isNationalLetter == isLetter) description:('isNationalLetter of ',ch codePoint asString).
    47 
    49 
    48 		    ucValue notNil ifTrue:[
    50                     ucValue notNil ifTrue:[
    49 			ucCh := Character value:ucValue.
    51                         ucCh := Character value:ucValue.
    50 			self assert:(ch asUppercase = ucCh) description:('asUppercase of ',ch codePoint asString).
    52                         self assert:(ch asUppercase = ucCh) description:('asUppercase of ',ch codePoint asString).
    51 		    ] ifFalse:[
    53                     ] ifFalse:[
    52 			self assert:(ch asUppercase = ch) description:('asUppercase of ',ch codePoint asString).
    54                         self assert:(ch asUppercase = ch) description:('asUppercase of ',ch codePoint asString).
    53 		    ].
    55                     ].
    54 		    lcValue notNil ifTrue:[
    56                     lcValue notNil ifTrue:[
    55 			lcCh := Character value:lcValue.
    57                         lcCh := Character value:lcValue.
    56 			self assert:(ch asLowercase = lcCh) description:('asLowercase of ',ch codePoint asString).
    58                         self assert:(ch asLowercase = lcCh) description:('asLowercase of ',ch codePoint asString).
    57 		    ] ifFalse:[
    59                     ] ifFalse:[
    58 			self assert:(ch asLowercase = ch) description:('asLowercase of ',ch codePoint asString).
    60                         self assert:(ch asLowercase = ch) description:('asLowercase of ',ch codePoint asString).
    59 		    ].
    61                     ].
    60 		    tcValue notNil ifTrue:[
    62                     tcValue notNil ifTrue:[
    61 			tcCh := Character value:tcValue.
    63                         tcCh := Character value:tcValue.
    62 			self assert:(ch asTitlecase = tcCh) description:('asTitlecase of ',ch codePoint asString).
    64                         self assert:(ch asTitlecase = tcCh) description:('asTitlecase of ',ch codePoint asString).
    63 		    ] ifFalse:[
    65                     ] ifFalse:[
    64 			self assert:(ch asTitlecase = ch) description:('asTitlecase of ',ch codePoint asString).
    66                         self assert:(ch asTitlecase = ch) description:('asTitlecase of ',ch codePoint asString).
    65 		    ].
    67                     ].
    66 		].
    68                 ].
    67 	].
    69         ].
    68 
    70 
    69     "
    71     "
    70      self new test01CaseTesting
    72      self new test01CaseTesting
    71     "
    73     "
    72 
    74