RegressionTests__StringTests.st
author Stefan Vogel <sv@exept.de>
Tue, 11 Jun 2019 10:34:41 +0200
changeset 2321 32ea6329f5ad
parent 2242 6ed9be004635
child 2327 bf482d49aeaf
permissions -rw-r--r--
class: stx_goodies_regression class changed: #classNamesAndAttributes make classes autoloaded that stc cannot compile (yet)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1990
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
     1
"{ Encoding: utf8 }"
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#StringTests
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
     8
	instanceVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
     9
	classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
    10
	poolDictionaries:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
    11
	category:'tests-Regression-Collections'
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1425
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    15
!StringTests class methodsFor:'queries'!
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    16
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    17
coveredClassNames
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    18
    "should be redefined to return a collection of classes which are tested by
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    19
     this suite/case.
1425
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    20
     If not redefined, coveredPackageNames should be.
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    21
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    22
     These classes can be instrumented for coverage analysis,
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    23
     before running the suite to provide coverage analysis/report"
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    24
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    25
    ^ #( String CharacterArray )
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    26
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    27
    "Created: / 06-07-2011 / 21:27:03 / cg"
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    28
! !
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    29
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    30
!StringTests methodsFor:'helpers'!
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    31
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    32
runAccessTestsOnInstancesOf:aStringClass
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    33
    |str s0 s1 s2 s3 s4 t|
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    34
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    35
    0 to:33 do:[:l |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    36
	str := aStringClass new:l.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    37
	str atAllPut:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    38
	self assert:( str isBlank ).
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    39
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    40
	1 to:l do:[:pos |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    41
	    str at:pos put:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    42
	    self assert:( str isBlank not ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    43
	    str at:pos put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    44
	].
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    45
    ].
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    46
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    47
    s0 := aStringClass new:0.
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    48
    self assert:s0 isEmpty.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    49
    self assert:s0 isEmptyOrNil.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    50
    self assert:s0 size == 0.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    51
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    52
    s1 := (aStringClass new:5) replaceFrom:1 with:'hello'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    53
    s2 := (aStringClass new:6) replaceFrom:1 with:' world'.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    54
    self assert:(s1 , s2) size == 11.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    55
    self assert:(s1 , s2) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    56
    self assert:(s1 = 'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    57
    self assert:(s2 = ' world').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    58
    self assert:(s1 size == 5).
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    59
    self assert:(s2 size == 6).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    60
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    61
    self assert:(s1 = 'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    62
    self assert:(s1 asSymbol == #'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    63
    self assert:(s1 copyFrom:1) = 'hello'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    64
    self assert:(s1 copyFrom:1) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    65
    self assert:(s1 copyFrom:1 to:3) = 'hel'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    66
    self assert:(s1 copyFrom:1 to:3) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    67
    self assert:(s1 copyWith:$X) = 'helloX'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    68
    self assert:(s1 copyWith:$X) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    69
    self assert:(s1 endsWith:'llo').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    70
    self assert:(s1 startsWith:'hel').
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    71
702
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    72
    self assert:(t := s1 identityIndexOf:$h) == 1 description:('identityIndex is %1 (should be 1)' bindWith:t).
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    73
    self assert:(t := s1 identityIndexOf:$l) == 3 description:('identityIndex is %1 (should be 3)' bindWith:t).
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    74
    self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    75
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    76
    self assert:(s1 identityIndexOf:$h startingAt:1) == 1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    77
    self assert:(s1 identityIndexOf:$h startingAt:2) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    78
    self assert:(s1 identityIndexOf:$e startingAt:1) == 2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    79
    self assert:(s1 identityIndexOf:$e startingAt:2) == 2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    80
    self assert:(s1 identityIndexOf:$l startingAt:1) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    81
    self assert:(s1 identityIndexOf:$l startingAt:2) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    82
    self assert:(s1 identityIndexOf:$l startingAt:3) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    83
    self assert:(s1 identityIndexOf:$l startingAt:4) == 4.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    84
    self assert:(s1 identityIndexOf:$l startingAt:5) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    85
    self assert:(s1 identityIndexOf:$l startingAt:6) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    86
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    87
    self assert:(s1 indexOf:$h) == 1.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    88
    self assert:(s1 indexOf:$l) == 3.
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    89
    self assert:(s1 indexOf:$L) == 0.
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    90
    self assert:(s1 indexOf:$A) == 0.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    91
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    92
    self assert:(s1 indexOf:$h startingAt:1) == 1.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    93
    self assert:(s1 indexOf:$h startingAt:2) == 0.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    94
    self assert:(s1 indexOf:$e startingAt:1) == 2.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    95
    self assert:(s1 indexOf:$e startingAt:2) == 2.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    96
    self assert:(s1 indexOf:$l startingAt:1) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    97
    self assert:(s1 indexOf:$l startingAt:2) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    98
    self assert:(s1 indexOf:$l startingAt:3) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    99
    self assert:(s1 indexOf:$l startingAt:4) == 4.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   100
    self assert:(s1 indexOf:$l startingAt:5) == 0.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   101
    self assert:(s1 indexOf:$l startingAt:6) == 0.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   102
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   103
    self assert:(s1 includes:$l).
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   104
    self assert:(s1 includes:$L) not.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   105
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   106
    self assert:(s1 includesAny:'a') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   107
    self assert:(s1 includesAny:'ab') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   108
    self assert:(s1 includesAny:'abc') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   109
    self assert:(s1 includesAny:'abcd') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   110
    self assert:(s1 includesAny:'abcde').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   111
    self assert:(s1 includesAny:'e').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   112
    self assert:(s1 includesAny:'ae').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   113
    self assert:(s1 includesAny:'ea').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   114
    self assert:(s1 includesAny:'abe').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   115
    self assert:(s1 includesAny:'eab').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   116
    self assert:(s1 includesAny:'aeb').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   117
    self assert:(s1 includesAny:'abce').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   118
    self assert:(s1 includesAny:'eabc').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   119
    self assert:(s1 includesAny:'aebc').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   120
    self assert:(s1 includesAny:'abec').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   121
    self assert:(s1 includesAny:'abcde').
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   122
						  " 12345678901234567890 "
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   123
    s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   124
    t := s3 asCollectionOfSubstringsSeparatedBy:$,.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   125
    self assert:(t size = 2).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   126
    self assert:(t first = '12 45').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   127
    self assert:(t second = '78;01.34-67+90').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   128
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   129
    t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   130
    self assert:(t size = 5).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   131
    self assert:(t first = '12').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   132
    self assert:(t second = '45').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   133
    self assert:(t third = '78').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   134
    self assert:(t fourth = '01').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   135
    self assert:(t fifth = '34-67+90').
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   136
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   137
    s4 := (aStringClass new:10) replaceFrom:1 with:'123',Character tab,'567',Character cr,'90'.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   138
    self assert:(s4 size = 10).
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   139
    self assert:(s4 indexOfSeparatorStartingAt:1) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   140
    self assert:(s4 indexOfSeparatorStartingAt:3) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   141
    self assert:(s4 indexOfSeparatorStartingAt:4) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   142
    self assert:(s4 indexOfSeparatorStartingAt:5) = 8.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   143
    self assert:(s4 indexOfControlCharacterStartingAt:1) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   144
    self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   145
    self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   146
    self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   147
    self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5.
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   148
! !
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   149
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   150
!StringTests methodsFor:'tests'!
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   151
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   152
test01_access
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   153
    0 to:33 do:[:l |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   154
	|str|
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   155
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   156
	str := String new:l.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   157
	str atAllPut:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   158
	self assert:( str isBlank ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   159
	self assert:((str size == 0) or: [(str first) == Character space.]).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   160
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   161
	1 to:l do:[:pos |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   162
	    str at:pos put:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   163
	    self assert:( str isBlank not ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   164
	    self assert:((str at:pos) == $a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   165
	    str at:pos put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   166
	].
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   167
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   168
    self runAccessTestsOnInstancesOf:String
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   169
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   170
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   171
     self new test01_access
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   172
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   173
!
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   174
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   175
test02_subclassAccess
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   176
    |myStringClass s1|
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   177
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   178
    Class withoutUpdatingChangesDo:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   179
	myStringClass := String
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   180
			subclass:#'MyString'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   181
			instanceVariableNames:'foo'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   182
			classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   183
			poolDictionaries:nil.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   184
	myStringClass compile:'foo ^foo'.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   185
	myStringClass compile:'foo:arg foo := arg'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   186
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   187
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   188
    s1 := (myStringClass new:5) replaceFrom:1 with:'hello'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   189
    self assert:(s1 foo isNil).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   190
    self assert:(s1 size == 5).
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   191
    s1 foo:16r11413344.         "/ ensure there is a $A inside (hex 41)
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   192
    self assert:(s1 foo == 16r11413344).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   193
    self assert:(s1 = 'hello').
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   194
    self assert:(s1 deepCopy foo == 16r11413344).
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   195
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   196
    self assert:((s1 indexOf:$A) == 0).                 "/ should not find the A
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   197
    self assert:((s1 identityIndexOf:$A) == 0).         "/ should not find the A
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   198
    self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   199
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   200
    self runAccessTestsOnInstancesOf:myStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   201
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   202
    "
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   203
     self new test02_subclassAccess
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   204
    "
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   205
!
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   206
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   207
test03a_unicode16
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   208
    |u s u2|
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   209
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   210
    u := 'hello' asUnicode16String.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   211
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   212
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   213
    self assert:((u at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   214
    self assert:((u at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   215
    self assert:((u at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   216
    self assert:((u at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   217
    self assert:((u at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   218
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   219
    s := u asSingleByteString.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   220
    self assert:(s class == String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   221
    self assert:(s size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   222
    self assert:((s at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   223
    self assert:((s at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   224
    self assert:((s at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   225
    self assert:((s at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   226
    self assert:((s at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   227
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   228
    s := u asSingleByteStringIfPossible.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   229
    self assert:(s class == String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   230
    self assert:(s size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   231
    self assert:((s at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   232
    self assert:((s at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   233
    self assert:((s at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   234
    self assert:((s at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   235
    self assert:((s at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   236
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   237
    u2 := 'hello' asUnicode16String.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   238
    u2 at:1 put:(Character codePoint:16r20AC).   "/ euro character
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   239
    self assert:(u2 size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   240
    self assert:((u2 at:1) = (Character codePoint:16r20AC)).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   241
    self assert:((u2 at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   242
    self assert:((u2 at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   243
    self assert:((u2 at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   244
    self assert:((u2 at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   245
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   246
    s := u2 asSingleByteStringIfPossible.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   247
    self assert:(s class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   248
    self assert:(u2 == s).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   249
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   250
    u := Unicode16String fromString:'hello'.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   251
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   252
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   253
    self assert:((u at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   254
    self assert:((u at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   255
    self assert:((u at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   256
    self assert:((u at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   257
    self assert:((u at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   258
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   259
    u replaceFrom:1 to:5 with:'abcde' startingAt:1.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   260
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   261
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   262
    self assert:((u at:1) == $a).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   263
    self assert:((u at:2) == $b).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   264
    self assert:((u at:3) == $c).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   265
    self assert:((u at:4) == $d).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   266
    self assert:((u at:5) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   267
    
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   268
    "
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   269
     self new test03a_unicode16
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   270
    "
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   271
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   272
    "Created: / 02-04-2019 / 10:43:49 / Claus Gittinger"
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   273
!
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   274
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   275
test03b_unicode32
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   276
    |u s u2|
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   277
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   278
    u := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   279
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   280
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   281
    self assert:((u at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   282
    self assert:((u at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   283
    self assert:((u at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   284
    self assert:((u at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   285
    self assert:((u at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   286
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   287
    s := u asSingleByteString.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   288
    self assert:(s class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   289
    self assert:(s size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   290
    self assert:((s at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   291
    self assert:((s at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   292
    self assert:((s at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   293
    self assert:((s at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   294
    self assert:((s at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   295
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   296
    s := u asSingleByteStringIfPossible.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   297
    self assert:(s class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   298
    self assert:(s size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   299
    self assert:((s at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   300
    self assert:((s at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   301
    self assert:((s at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   302
    self assert:((s at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   303
    self assert:((s at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   304
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   305
    u2 := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   306
    u2 at:1 put:(Character codePoint:16r20AC).   "/ euro character
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   307
    self assert:(u2 size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   308
    self assert:((u2 at:1) = (Character codePoint:16r20AC)).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   309
    self assert:((u2 at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   310
    self assert:((u2 at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   311
    self assert:((u2 at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   312
    self assert:((u2 at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   313
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   314
    s := u2 asSingleByteStringIfPossible.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   315
    self assert:(s class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   316
    self assert:(u2 == s).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   317
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   318
    u := Unicode32String fromString:'hello'.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   319
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   320
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   321
    self assert:((u at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   322
    self assert:((u at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   323
    self assert:((u at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   324
    self assert:((u at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   325
    self assert:((u at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   326
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   327
    u replaceFrom:1 to:5 with:'abcde' startingAt:1.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   328
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   329
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   330
    self assert:((u at:1) == $a).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   331
    self assert:((u at:2) == $b).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   332
    self assert:((u at:3) == $c).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   333
    self assert:((u at:4) == $d).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   334
    self assert:((u at:5) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   335
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   336
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   337
     self new test03b_unicode32
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   338
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   339
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   340
    "Created: / 02-04-2019 / 10:44:34 / Claus Gittinger"
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   341
!
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   342
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   343
test03c_unicodeStrings
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   344
    |u32 u16 u8|
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   345
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   346
    u32 := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   347
    u16 := 'hello' asUnicode16String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   348
    u8 := 'hello' asString.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   349
    self assert:(u32 = u16).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   350
    self assert:(u16 = u32).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   351
    self assert:(u32 = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   352
    self assert:(u8 = u32).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   353
    self assert:(u16 = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   354
    self assert:(u8 = u16).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   355
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   356
    self assert:(u32 asDenseUnicodeString = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   357
    self assert:(u32 asDenseUnicodeString class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   358
    self assert:(u16 asDenseUnicodeString = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   359
    self assert:(u16 asDenseUnicodeString class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   360
    self assert:(u8 asDenseUnicodeString == u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   361
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   362
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   363
     self new test03c_unicodeStrings
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   364
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   365
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   366
    "Created: / 02-04-2019 / 10:46:10 / Claus Gittinger"
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   367
!
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   368
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   369
test10_Contains8BitCharacters
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   370
    0 to:65 do:[:l |
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   371
	|str|
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   373
	str := String new:l.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   374
	str atAllPut:(Character value:16r7F).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   375
	self assert:( str contains8BitCharacters not ).
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   377
	1 to:l do:[:pos |
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   378
	    str at:pos put:(Character value:16r80).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   379
	    self assert:( str contains8BitCharacters ).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   380
	    str at:pos put:(Character value:16r7F).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   381
	].
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    ].
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    "
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   385
     self new test10_Contains8BitCharacters
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    "
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   387
!
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   388
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   389
test11_IsEmpty
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   390
    |nul n|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   391
    nul := 0 asCharacter.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   392
    n := 1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   393
    self assert:('' isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   394
    self assert:(' ' isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   395
    self assert:(nul asCharacter asString isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   396
    self assert:(('' , nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   397
    self assert:((String new:0) isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   398
    self assert:((String new:17 withAll:nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   399
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   400
    29 timesRepeat:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   401
	|s|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   402
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   403
	s := String new:(n + 17).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   404
	self assert:(s isEmpty not).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   405
	n := n * 2.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   406
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   407
    self assert:((String new:17 withAll:nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   408
    self assert:((String new:0 withAll:nul) isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   409
    "
1429
0201c6bd39a4 #DOCUMENTATION by mawalch
mawalch
parents: 1428
diff changeset
   410
     self new test11_IsEmpty
0201c6bd39a4 #DOCUMENTATION by mawalch
mawalch
parents: 1428
diff changeset
   411
    "
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   412
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   413
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   414
test12_Comparison
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   415
    0 to: 255 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   416
	|s t|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   417
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   418
	1 to: 9 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   419
	    s := String new:j withAll:(i asCharacter).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   420
	    t := s copy.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   421
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   422
	    self assert:(s notNil).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   423
	    self assert:(s = s).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   424
	    self assert:(s ~= s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   425
	    self assert:(s < s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   426
	    self assert:(s > s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   427
	    self assert:(s = (s,s)) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   428
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   429
	    self assert:(t notNil).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   430
	    self assert:(s = t).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   431
	    self assert:(s ~= t) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   432
	    self assert:(s < t) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   433
	    self assert:(s > t) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   434
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   435
	    self assert:((s = nil) == ((s ~= nil) not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   436
	    self assert:((s = '') == ((s ~= '') not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   437
	].
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   438
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   439
	s := i asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   440
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   441
	    t := j asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   442
	    self assert:(t notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   443
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   444
	    self assert:((s = t) == ((s ~= t) not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   445
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   446
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   447
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   448
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   449
     self new test12_Comparison
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   450
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   451
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   452
1990
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   453
test13_startsWithEndsWithSameAs
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   454
    self assert:('hello' startsWith:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   455
    self assert:('hello' startsWith:'h').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   456
    self assert:('hello' startsWith:'he').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   457
    self assert:('hello' startsWith:'hel').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   458
    self assert:('hello' startsWith:'hell').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   459
    self assert:('hello' startsWith:'hello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   460
    self assert:('hello' startsWith:'hello world') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   461
    "/ int size
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   462
    self assert:('1234' startsWith:'123').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   463
    self assert:('1234' startsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   464
    self assert:('1234' startsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   465
    self assert:('12345678' startsWith:'123').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   466
    self assert:('12345678' startsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   467
    self assert:('12345678' startsWith:'12345').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   468
    self assert:('12345678' startsWith:'123456').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   469
    self assert:('12345678' startsWith:'1234567').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   470
    self assert:('12345678' startsWith:'12345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   471
    self assert:('12345678' startsWith:'123456789') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   472
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   473
    self assert:('1234' startsWith:'x23') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   474
    self assert:('1234' startsWith:'x234') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   475
    self assert:('1234' startsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   476
    self assert:('1234' startsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   477
    self assert:('1234' startsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   478
    self assert:('1234' startsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   479
    self assert:('12345678' startsWith:'x234') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   480
    self assert:('12345678' startsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   481
    self assert:('12345678' startsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   482
    self assert:('12345678' startsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   483
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   484
    self assert:('hello' endsWith:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   485
    self assert:('hello' endsWith:'o').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   486
    self assert:('hello' endsWith:'lo').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   487
    self assert:('hello' endsWith:'llo').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   488
    self assert:('hello' endsWith:'ello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   489
    self assert:('hello' endsWith:'hello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   490
    self assert:('hello' endsWith:'hello world') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   491
    "/ int size
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   492
    self assert:('1234' endsWith:'234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   493
    self assert:('1234' endsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   494
    self assert:('1234' endsWith:'1235') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   495
    self assert:('1234' endsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   496
    self assert:('12345678' endsWith:'678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   497
    self assert:('12345678' endsWith:'5678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   498
    self assert:('12345678' endsWith:'45678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   499
    self assert:('12345678' endsWith:'345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   500
    self assert:('12345678' endsWith:'2345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   501
    self assert:('12345678' endsWith:'12345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   502
    self assert:('12345678' endsWith:'123456789') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   503
    self assert:('12345678' endsWith:'012345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   504
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   505
    self assert:('1234' endsWith:'x233') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   506
    self assert:('1234' endsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   507
    self assert:('1234' endsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   508
    self assert:('1234' endsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   509
    self assert:('12345678' endsWith:'x2345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   510
    self assert:('12345678' endsWith:'1x345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   511
    self assert:('12345678' endsWith:'12x45678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   512
    self assert:('12345678' endsWith:'123x5678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   513
    self assert:('12345678' endsWith:'1234x678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   514
    self assert:('12345678' endsWith:'12345x78') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   515
    self assert:('12345678' endsWith:'123456x8') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   516
    self assert:('12345678' endsWith:'1234567x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   517
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   518
    self assert:('' sameAs:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   519
    self assert:('' sameAs:'a') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   520
    self assert:('a' sameAs:'') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   521
    self assert:('a' sameAs:'a').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   522
    self assert:('a' sameAs:'A').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   523
    self assert:('A' sameAs:'A').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   524
    self assert:('A' sameAs:'a').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   525
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   526
    self assert:('a' sameAs:'1') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   527
    self assert:('A' sameAs:'1') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   528
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   529
    1 to:20 do:[:len |
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   530
        |s1 s2|
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   531
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   532
        s1 := ($a to:($a + len - 1)) asString.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   533
        s2 := s1 copy.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   534
        1 to:len do:[:idx |
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   535
            s2 at:idx put:(s2 at:idx) asUppercase.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   536
            self assert:(s1 sameAs:s2).
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   537
        ].
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   538
    ].
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   539
    
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   540
    self assert:('Ä' sameAs:'ä').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   541
    self assert:('Ä' sameAs:'ä').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   542
    self assert:('ß' sameAs:'ÿ') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   543
    self assert:('Ÿ' sameAs:'ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   544
    self assert:('Ÿ' sameAs:'Ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   545
    self assert:('ÿ' sameAs:'ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   546
    
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   547
    "
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   548
     self new test13_startsWithEndsWithSameAs
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   549
    "
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   550
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   551
    "Created: / 19-07-2018 / 11:05:32 / Claus Gittinger"
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   552
!
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   553
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   554
test15_CompareWithCollating
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   555
    | nul |
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   556
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   557
    nul := 0 asCharacter asString.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   558
    self assert:('' compareWith:'' collating:true) == 0.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   559
    self assert:('' compareWith:'' collating:false) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   560
    self assert:(nul compareWith:(255 asCharacter asString) collating:false) == -1.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   561
    self assert:((255 asCharacter asString) compareWith:nul collating:false) == 1.
1433
6291f067c336 #REFACTORING by mawalch
mawalch
parents: 1430
diff changeset
   562
    "/ This will fail and is a WONTFIX
6291f067c336 #REFACTORING by mawalch
mawalch
parents: 1430
diff changeset
   563
    "/ self assert:((('' compareWith:nul collating:false) == 0) == ('' = nul)).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   564
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   565
    0 to: 255 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   566
	|s|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   567
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   568
	s := i asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   569
	self assert:(s notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   570
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   571
	"/ This will fail and is a WONTFIX
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   572
	"/ self assert:('' compareWith:s collating:false) ~= 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   573
	self assert:('' compareWith:s collating:false) == ((s compareWith:'' collating:false) negated).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   574
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   575
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   576
	    | t |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   577
	    t := j asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   578
	    self assert:(t notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   579
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   580
	    self assert:(((s compareWith:t collating:false) == -1) == (s < t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   581
	    self assert:(((s compareWith:t collating:false) == 0) == (s = t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   582
	    self assert:(((s compareWith:t collating:false) == 1) == (s > t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   583
	    self assert:(((s compareWith:t collating:true) == -1) == (s < t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   584
	    self assert:(((s compareWith:t collating:true) == 0) == (s = t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   585
	    self assert:(((s compareWith:t collating:true) == 1) == (s > t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   586
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   587
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   588
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   589
    0 to: 9 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   590
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   591
	    |s t|
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   592
	    s := String new:i withAll:(j asCharacter).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   593
	    t := s copy.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   594
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   595
	    self assert: (s compareWith:s collating:false) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   596
	    self assert: (s compareWith:s collating:true) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   597
	    self assert: (s compareWith:t collating:false) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   598
	    self assert: (s compareWith:t collating:true) == 0
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   599
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   600
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   601
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   602
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   603
     self new test15_CompareWithCollating
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   604
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   605
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   606
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   607
test20_literalsAreReadonly
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   608
    |myClass s1 l2 s2 parserFlags compiler|
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   609
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   610
    parserFlags := Compiler new parserFlags copy.
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   611
    parserFlags stringsAreImmutable:true.
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   612
    parserFlags arraysAreImmutable:true.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   613
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   614
    Class withoutUpdatingChangesDo:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   615
	myClass := Object
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   616
			subclass:#'MyClass'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   617
			instanceVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   618
			classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   619
			poolDictionaries:nil.
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   620
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   621
	compiler := myClass compilerClass new.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   622
	compiler parserFlags:parserFlags.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   623
	compiler compile:'lit1 ^''hello''' forClass:myClass install:true.
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   624
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   625
	compiler := myClass compilerClass new.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   626
	compiler parserFlags:parserFlags.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   627
	compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   628
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   629
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   630
    s1 := myClass new perform:#lit1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   631
    self assert:(s1 isString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   632
    self assert:(s1 class == ImmutableString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   633
    self should:[ s1 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   634
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   635
    l2 := myClass new perform:#lit2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   636
    self assert:(l2 isArray).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   637
    self assert:(l2 class == ImmutableArray).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   638
    self should:[ l2 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   639
    s2 := l2 at:1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   640
    self assert:(s2 isString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   641
    self assert:(s2 class == ImmutableString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   642
    self should:[ s2 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   643
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   644
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   645
     self new test20_literalsAreReadonly
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   646
    "
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   647
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   648
    "Modified: / 02-08-2011 / 19:30:53 / cg"
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   649
!
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   650
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   651
test30_indexOfSubCollection
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   652
    |i|
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   653
      "/  12345678901
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   654
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   655
    self assert:(i == 7).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   656
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   657
    self assert:(i == 0).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   658
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   659
    self assert:(i == 7).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   660
    i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   661
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   662
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   663
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   664
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   665
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   666
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   667
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   668
    self assert:(i == 15).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   669
353
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   670
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   671
    self assert:(i == 16).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   672
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   673
    self assert:(i == 0).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   674
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   675
    self assert:(i == 0).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   676
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   677
    i := 'world' indexOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   678
    self assert:(i == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   679
    i := 'world' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   680
    self assert:(i == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   681
    i := 'world' indexOfString:'world' startingAt:6.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   682
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   683
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   684
    i := 'hello world' indexOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   685
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   686
    i := 'hello world' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   687
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   688
    i := 'hello world' indexOfString:'world' startingAt:4.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   689
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   690
    i := 'hello world' indexOfString:'world' startingAt:7.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   691
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   692
    i := 'hello world' indexOfString:'world' startingAt:8.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   693
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   694
    
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   695
    i := 'hello wOrLd' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   696
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   697
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   698
    "
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   699
     self new test30_indexOfSubCollection
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   700
    "
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   701
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   702
    "Modified: / 25-05-2019 / 09:01:43 / Claus Gittinger"
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   703
!
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   704
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   705
test31_occurrencesOfString
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   706
    |n|
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   707
      "/  12345678901
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   708
    n := 'hello world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   709
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   710
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   711
    n := 'hello wOrLd world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   712
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   713
2242
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   714
    n := 'hello wOrLd world' occurrencesOfString:'world' caseSensitive:false.
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   715
    self assert:(n == 2).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   716
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   717
    n := 'hello world hello world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   718
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   719
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   720
    n := '' occurrencesOfString:'aa'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   721
    self assert:(n == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   722
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   723
    n := 'a' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   724
    self assert:(n == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   725
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   726
    n := 'aa' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   727
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   728
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   729
    n := ' aa ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   730
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   731
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   732
    n := ' aa a' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   733
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   734
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   735
    n := ' aaaa' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   736
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   737
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   738
    n := ' aa aa ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   739
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   740
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   741
    n := ' aa bb ab ba aa ab' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   742
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   743
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   744
    n := ' aa bb cc aa bb cc aa bb ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   745
    self assert:(n == 3).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   746
2242
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   747
    n := ' aa bb cc aA bb cc Aa bb ' occurrencesOfString:'aa'.  
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   748
    self assert:(n == 1).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   749
    n := ' aa bb cc aA bb cc Aa bb ' occurrencesOfString:'aa' caseSensitive:false.  
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   750
    self assert:(n == 3).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   751
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   752
    "
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   753
     self new test31_occurrencesOfString
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   754
    "
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   755
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   756
    "Created: / 25-05-2019 / 09:03:11 / Claus Gittinger"
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   757
!
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   758
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   759
test40_indexOfAny
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   760
    |s i collection|
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   761
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   762
    s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'.
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   763
    1 to:s size do:[:start |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   764
	i := s indexOfAny:'-' startingAt:start.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   765
	self assert:(i == 0 or:[ i >= start]).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   766
	(i ~~ 0) ifTrue:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   767
	    self assert:(s at:i) == $-
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   768
	].
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   769
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   770
    "/    123456789012
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   771
    s := 'bla bla 1234'.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   772
    1 to:s size do:[:start |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   773
	i := s indexOfAny:'1234' startingAt:start.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   774
	self assert:(i == 0 or:[ i >= start]).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   775
	(i == 9) ifTrue:[ self assert:((s at:i) == $1) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   776
	(i == 10) ifTrue:[ self assert:((s at:i) == $2) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   777
	(i == 11) ifTrue:[ self assert:((s at:i) == $3) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   778
	(i == 12) ifTrue:[ self assert:((s at:i) == $4) ].
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   779
    ].
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   780
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   781
    collection := #($o, $l, $o).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   782
      "/  12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   783
    i := 'hello world' indexOfAny:collection startingAt:1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   784
    self assert:(i == 3).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   785
    i := 'hello world' indexOfAny:collection startingAt:2.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   786
    self assert:(i == 3).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   787
    i := 'hello world' indexOfAny:collection startingAt:3.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   788
    self assert:(i == 3).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   789
    i := 'hello world' indexOfAny:collection startingAt:4.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   790
    self assert:(i == 4).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   791
    i := 'hello world' indexOfAny:collection startingAt:5.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   792
    self assert:(i == 5).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   793
    i := 'hello world' indexOfAny:collection startingAt:6.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   794
    self assert:(i == 8).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   795
    i := 'hello world' indexOfAny:collection startingAt:7.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   796
    self assert:(i == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   797
    i := 'hello world' indexOfAny:collection startingAt:8.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   798
    self assert:(i == 8).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   799
    i := 'hello world' indexOfAny:collection startingAt:9.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   800
    self assert:(i == 10).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   801
    i := 'hello world' indexOfAny:collection startingAt:10.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   802
    self assert:(i == 10).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   803
    i := 'hello world' indexOfAny:collection startingAt:11.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   804
    self assert:(i == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   805
    i := 'hello world' indexOfAny:collection startingAt:12.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   806
    self assert:(i == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   807
    i := 'hello world' indexOfAny:collection startingAt:10000.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   808
    self assert:(i == 0).
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   809
    "
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   810
     self new test40_indexOfAny
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   811
    "
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   812
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   813
    "Created: / 29-10-2010 / 14:58:21 / cg"
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   814
!
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   815
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   816
test41_contains
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   817
    |s|
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   818
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   819
    s := 'abcdefg'.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   820
    self assert:(s contains:[:ch | ch == $a]).
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   821
    self assert:(s contains:[:ch | ch == $A]) not.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   822
    self assert:(s contains:[:ch | ch == $1]) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   823
    self assert:(s contains:[:ch | ch == (0 asCharacter)]) not.
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   824
    "
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   825
     self new test41_contains
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   826
    "
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   827
!
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   828
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   829
test42a_includesAny
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   830
    |s|
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   831
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   832
    1 to:20 do:[:na |
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   833
        s := (String new:na withAll:$a),'bla bla 1234'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   834
        self assert:( s includesAny:'12').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   835
        self assert:( s includesAny:'21').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   836
        self assert:( s includesAny:'15').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   837
        self assert:( s includesAny:'51').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   838
        self assert:( s includesAny:'45').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   839
        self assert:( s includesAny:'54').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   840
        self assert:( s includesAny:'56') not.
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   841
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   842
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   843
    "
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   844
     self new test42a_includesAny
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   845
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   846
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   847
    "Created: / 02-04-2019 / 11:03:13 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   848
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   849
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   850
test42b_includesMatchCharacters
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   851
    self assert:('hello' includesMatchCharacters not).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   852
    self assert:('he*llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   853
    self assert:('h[eE]llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   854
    self assert:('h#llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   855
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   856
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   857
     self new test42b_includesMatchCharacters
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   858
    "
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   859
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   860
    "Created: / 02-04-2019 / 11:03:46 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   861
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   862
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   863
test42c_includesSeparator
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   864
    self assert:('hello' includesSeparator not).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   865
    self assert:('he llo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   866
    self assert:(' hello' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   867
    self assert:('hello ' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   868
    self assert:(' he llo ' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   869
    self assert:(c'h\nllo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   870
    self assert:(c'h\tllo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   871
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   872
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   873
     self new test42c_includesSeparator
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   874
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   875
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   876
    "Created: / 02-04-2019 / 11:05:39 / Claus Gittinger"
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   877
!
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   878
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   879
test43_occurrencesOf
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   880
    |s|
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   881
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   882
    "/             12345678901
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   883
    self assert:( 'hello world' occurrencesOf:$0 ) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   884
    self assert:( 'hello world' occurrencesOf:$l ) == 3.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   885
    self assert:( 'hello world' occurrencesOf:$d ) == 1.
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   886
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   887
    "/ how about 0-bytes in between
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   888
    self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   889
    self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   890
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   891
    1 to:10 do:[:nA |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   892
	1 to:10 do:[:nB |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   893
	    s := (String new:nA withAll:$a),(String new:nB withAll:$b).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   894
	    self assert:(s occurrencesOf:$a) == nA.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   895
	    self assert:(s occurrencesOf:$b) == nB.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   896
	]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   897
    ].
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   898
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   899
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   900
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   901
    s at:512 put:(Character space).
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   902
    self assert:(s occurrencesOf:(Character space)) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   903
    self assert:(s occurrencesOf:$a) == 1023.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   904
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   905
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   906
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   907
    1 to:1024 by:2 do:[:i | s at:i put:$b].
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   908
    self assert:(s occurrencesOf:$a) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   909
    self assert:(s occurrencesOf:$b) == 512.
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   910
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   911
    "
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   912
     self new test43_occurrencesOf
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   913
    "
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   914
!
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   915
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   916
test50_indexOf
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   917
    |s i|
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   918
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   919
    s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'.
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   920
    1 to:s size do:[:start |
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   921
        i := s indexOf:$- startingAt:start.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   922
        self assert:(i == 0 or:[ i >= start]).
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   923
    ].
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   924
    "/             12345678901
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   925
    self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   926
    self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   927
    self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   928
    self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11.
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   929
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   930
    "/             12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   931
    self assert:(('hello world' indexOf:$o startingAt:1) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   932
    self assert:(('hello world' indexOf:$o startingAt:2) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   933
    self assert:(('hello world' indexOf:$o startingAt:3) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   934
    self assert:(('hello world' indexOf:$o startingAt:4) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   935
    self assert:(('hello world' indexOf:$o startingAt:5) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   936
    self assert:(('hello world' indexOf:$o startingAt:6) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   937
    self assert:(('hello world' indexOf:$o startingAt:7) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   938
    self assert:(('hello world' indexOf:$o startingAt:8) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   939
    self assert:(('hello world' indexOf:$o startingAt:9) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   940
    self assert:(('hello world' indexOf:$o startingAt:10) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   941
    self assert:(('hello world' indexOf:$o startingAt:11) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   942
    self assert:(('hello world' indexOf:$o startingAt:12) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   943
    self assert:(('hello world' indexOf:$o startingAt:10000) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   944
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   945
    "/ how about 0-bytes in between
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   946
    self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   947
    self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   948
    self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   949
    self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   950
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   951
    s := '12345678901234b'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   952
    self assert:(s indexOf:$x) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   953
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   954
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   955
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   956
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   957
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   958
    self assert:(s indexOf:$0) == 10.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   959
    self assert:(s indexOf:$b) == 15.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   960
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   961
    s := ''.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   962
    self assert:(s indexOf:$1) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   963
    s := '1'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   964
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   965
    self assert:(s indexOf:$2) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   966
    s := '12'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   967
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   968
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   969
    self assert:(s indexOf:$3) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   970
    s := '123'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   971
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   972
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   973
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   974
    self assert:(s indexOf:$4) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   975
    s := '1234'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   976
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   977
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   978
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   979
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   980
    self assert:(s indexOf:$5) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   981
    s := '12345'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   982
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   983
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   984
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   985
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   986
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   987
    self assert:(s indexOf:$6) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   988
    s := '123456'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   989
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   990
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   991
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   992
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   993
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   994
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   995
    self assert:(s indexOf:$7) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   996
    s := '1234567'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   997
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   998
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   999
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1000
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1001
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1002
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1003
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1004
    self assert:(s indexOf:$8) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1005
    s := '12345678'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1006
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1007
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1008
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1009
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1010
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1011
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1012
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1013
    self assert:(s indexOf:$8) == 8.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1014
    self assert:(s indexOf:$9) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1015
    s := '123456789'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1016
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1017
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1018
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1019
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1020
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1021
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1022
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1023
    self assert:(s indexOf:$8) == 8.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1024
    self assert:(s indexOf:$9) == 9.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1025
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1026
    self assert:(s indexOf:$0) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1027
    self assert:(s indexOf:$b) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1028
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1029
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1030
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1031
    s at:512 put:(Character space).
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1032
    self assert:(s indexOf:(Character space)) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1033
    self assert:(s indexOf:(Character space) startingAt:1) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1034
    self assert:(s indexOf:(Character space) startingAt:2) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1035
    self assert:(s indexOf:(Character space) startingAt:3) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1036
    self assert:(s indexOf:(Character space) startingAt:4) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1037
    self assert:(s indexOf:(Character space) startingAt:5) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1038
    self assert:(s indexOf:(Character space) startingAt:6) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1039
    self assert:(s indexOf:(Character space) startingAt:7) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1040
    self assert:(s indexOf:(Character space) startingAt:8) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1041
    self assert:(s indexOf:(Character space) startingAt:9) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1042
    self assert:(s indexOf:(Character space) startingAt:511) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1043
    self assert:(s indexOf:(Character space) startingAt:512) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1044
    self assert:(s indexOf:(Character space) startingAt:513) == 0.
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1045
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1046
    self assert:(s indexOfSeparator) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1047
    self assert:(s indexOfSeparatorStartingAt:1) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1048
    self assert:(s indexOfSeparatorStartingAt:2) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1049
    self assert:(s indexOfSeparatorStartingAt:3) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1050
    self assert:(s indexOfSeparatorStartingAt:4) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1051
    self assert:(s indexOfSeparatorStartingAt:5) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1052
    self assert:(s indexOfSeparatorStartingAt:6) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1053
    self assert:(s indexOfSeparatorStartingAt:7) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1054
    self assert:(s indexOfSeparatorStartingAt:8) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1055
    self assert:(s indexOfSeparatorStartingAt:9) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1056
    self assert:(s indexOfSeparatorStartingAt:511) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1057
    self assert:(s indexOfSeparatorStartingAt:512) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1058
    self assert:(s indexOfSeparatorStartingAt:513) == 0.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1059
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1060
    "
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1061
     self new test50_indexOf
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1062
    "
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1063
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1064
    "Created: / 29-10-2010 / 14:58:21 / cg"
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1065
    "Modified: / 02-04-2019 / 11:06:52 / Claus Gittinger"
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1066
!
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1067
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1068
test51_substrings
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1069
    self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc').
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1070
    self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'.
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1071
2083
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1072
    self assert:('aaa/bbb' withoutSuffix:'bbb') = 'aaa/'.
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1073
    self assert:('aaa/bbb' withoutPrefix:'aaa') = '/bbb'.
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1074
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1075
"/    self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1076
"/    self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1077
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1078
"/    self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ).
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1079
"/    self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1080
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1081
"/    self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' '').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1082
"/    self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1083
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1084
"/    self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1085
"/    self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'.
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1086
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1087
    "
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1088
     self new test51_substrings
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1089
    "
2083
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1090
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1091
    "Modified: / 11-02-2019 / 23:57:03 / Claus Gittinger"
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1092
!
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1093
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1094
test52_indexOfSeparator
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1095
    |j s|
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1096
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1097
    self assert:('' indexOfSeparator) == 0.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1098
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1099
	s := (String new:n withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1100
	1 to:20 do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1101
	    self assert:(s indexOfSeparatorStartingAt:start) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1102
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1103
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1104
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1105
	s := (String new:n withAll:$a),' '.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1106
	1 to:n do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1107
	    self assert:(s indexOfSeparatorStartingAt:start) == (n+1).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1108
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1109
    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1110
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1111
    {
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1112
	Character space .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1113
	Character tab .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1114
	Character return .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1115
	Character lf .
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1116
    } do:[:sep |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1117
	1 to:20 do:[:na |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1118
	    1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1119
		s := (String new:na withAll:$a),sep,(String new:na withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1120
		1 to:na do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1121
		    self assert:(s indexOfSeparatorStartingAt:start) == (na+1).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1122
		]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1123
	    ]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1124
	].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1125
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1126
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1127
    {
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1128
	Character esc .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1129
	Character null .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1130
	$a .
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1131
    } do:[:nonSep |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1132
	1 to:20 do:[:na |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1133
	    1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1134
		s := (String new:na withAll:$a),nonSep,(String new:na withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1135
		1 to:20 do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1136
		    self assert:(s indexOfSeparatorStartingAt:start) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1137
		]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1138
	    ]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1139
	].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1140
    ].
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1141
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1142
    s := String new:1000 withAll:$a.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1143
    self assert:(s indexOfSeparatorStartingAt:1) == 0.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1144
    400 to: 417 do:[:i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1145
	s := String new:1000 withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1146
	s at:i put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1147
	self assert:(s indexOfSeparatorStartingAt:1) == i.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1148
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1149
	s := String new:1000 withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1150
	s at:i put:(Character return).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1151
	self assert:(s indexOfSeparatorStartingAt:1) == i.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1152
    ].
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1153
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1154
      "/  12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1155
    j := 'hello world' indexOfSeparatorStartingAt:1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1156
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1157
    j := 'hello world ' indexOfSeparatorStartingAt:2.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1158
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1159
    j := 'hello world ' indexOfSeparatorStartingAt:3.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1160
    self assert:(j == 6).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1161
    j := 'hello world ' indexOfSeparatorStartingAt:4.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1162
    self assert:(j == 6).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1163
    j := 'hello world ' indexOfSeparatorStartingAt:5.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1164
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1165
    j := 'hello world ' indexOfSeparatorStartingAt:6.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1166
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1167
    j := 'hello world ' indexOfSeparatorStartingAt:7.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1168
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1169
    j := 'hello world ' indexOfSeparatorStartingAt:8.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1170
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1171
    j := 'hello world ' indexOfSeparatorStartingAt:9.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1172
    self assert:(j == 12).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1173
    j := 'hello world ' indexOfSeparatorStartingAt:10.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1174
    self assert:(j == 12).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1175
    j := 'hello world ' indexOfSeparatorStartingAt:11.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1176
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1177
    j := 'hello world ' indexOfSeparatorStartingAt:12.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1178
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1179
    j := 'hello world' indexOfSeparatorStartingAt:12.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1180
    self assert:(j == 0).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1181
    j := 'hello world ' indexOfSeparatorStartingAt:13.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1182
    self assert:(j == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1183
    j := 'hello world ' indexOfSeparatorStartingAt:10000.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1184
    self assert:(j == 0).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1185
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1186
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1187
     self new test52_indexOfSeparator
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1188
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1189
!
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1190
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1191
test54_occurrencesOf
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1192
    |s|
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1193
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1194
    self assert:('' occurrencesOf:$a) == 0.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1195
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1196
	s := (String new:n withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1197
	self assert:(s occurrencesOf:$a) == n.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1198
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1199
    1 to:20 do:[:na |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1200
	1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1201
	    s := (String new:na withAll:$a),(String new:nb withAll:$b).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1202
	    self assert:(s occurrencesOf:$a) == na.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1203
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1204
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1205
    1 to:40 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1206
	s := String new:n withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1207
	1 to:n by:2 do:[:n |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1208
	    s at:n put:$b.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1209
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1210
	self assert:(s occurrencesOf:$a) == (n // 2).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1211
    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1212
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1213
    s := String new:1000 withAll:$a.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1214
    self assert:(s occurrencesOf:$a) == 1000.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1215
    1 to:1000 do:[:i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1216
	s at:i put:$b.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1217
	self assert:(s occurrencesOf:$a) == (1000-i).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1218
	self assert:(s occurrencesOf:$b) == i.
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1219
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1220
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1221
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1222
     self new test54_occurrencesOf
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1223
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1224
!
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1225
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1226
test60a_hash
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1227
    "
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1228
    As of 2013-01-09 for strings of size 7 String & Unicode16String hash
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1229
    returned different values. This test checks this
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1230
    "
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1231
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1232
    | tester |
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1233
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1234
    tester := [:s|
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1235
        |sHash u16Hash u32Hash|
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1236
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1237
        sHash := s hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1238
        u16Hash := s asUnicode16String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1239
        u32Hash := s asUnicode32String hash.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1240
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1241
        self assert: sHash == u16Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1242
             description: ('String and Unicode16String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1243
                                bindWith:s with:s class name).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1244
        self assert: sHash == u32Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1245
             description: ('String and Unicode32String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1246
                                bindWith:s with:s class name)
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1247
    ].
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1248
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1249
    tester value:'a'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1250
    tester value:'123456789012345678'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1251
    tester value:'12345678901234567'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1252
    tester value:'1234567890123456'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1253
    tester value:'123456789012345'.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1254
    tester value:'12345678901234'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1255
    tester value:'1234567890123'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1256
    tester value:'123456789012'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1257
    tester value:'12345678901'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1258
    tester value:'1234567890'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1259
    tester value:'123456789'.
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1260
    tester value:'12345678'.
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1261
    tester value:'1234567'.
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1262
    tester value:'123456'.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1263
    tester value:'12345'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1264
    tester value:'1234'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1265
    tester value:'123'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1266
    tester value:'12'.
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1267
    tester value:'boolean'.
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1268
1417
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1269
    "/ strings with 0-elements
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1270
    tester value:('' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1271
    tester value:('1' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1272
    tester value:('12' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1273
    tester value:('123' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1274
    tester value:('1234' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1275
    tester value:('12345' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1276
    tester value:('123456' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1277
    tester value:('1234567' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1278
    tester value:('12345678' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1279
    tester value:('123456789' copyWith:Character null).
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1280
    tester value:('1234567890' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1281
    tester value:('12345678901' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1282
    tester value:('123456789012' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1283
    tester value:('1234567890123' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1284
    tester value:('12345678901234' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1285
    tester value:('123456789012345' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1286
    tester value:('1234567890123456' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1287
    tester value:('12345678901234567' copyWith:Character null).
1419
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1288
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1289
    tester value:('' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1290
    tester value:('1' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1291
    tester value:('12' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1292
    tester value:('123' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1293
    tester value:('1234' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1294
    tester value:('12345' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1295
    tester value:('123456' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1296
    tester value:('1234567' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1297
    tester value:('12345678' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1298
    tester value:('123456789' copyWith:Character null),'123'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1299
    tester value:('1234567890' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1300
    tester value:('12345678901' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1301
    tester value:('123456789012' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1302
    tester value:('1234567890123' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1303
    tester value:('12345678901234' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1304
    tester value:('123456789012345' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1305
    tester value:('1234567890123456' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1306
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1307
    "Created: / 02-04-2019 / 10:55:23 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1308
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1309
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1310
test60b_hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1311
    | tester |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1312
2212
80b766225587 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1313
    "/ self skip:'takes long'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1314
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1315
    tester := [:s|
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1316
        |sHash u16Hash u32Hash|
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1317
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1318
        sHash := s hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1319
        u16Hash := s asUnicode16String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1320
        u32Hash := s asUnicode32String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1321
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1322
        self assert: sHash == u16Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1323
             description: ('String and Unicode16String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1324
                                bindWith:s with:s class name).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1325
        self assert: sHash == u32Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1326
             description: ('String and Unicode32String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1327
                                bindWith:s with:s class name)
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1328
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1329
1419
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1330
    "/ String allInstancesDo:[:each| tester value:each].
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1331
    Symbol allInstancesDo:[:each| tester value:each].
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1332
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1333
    "Created: / 02-04-2019 / 10:55:26 / Claus Gittinger"
962
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1334
!
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1335
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1336
test65_concatenation
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1337
    |strA strB|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1338
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1339
    0 to:32 do:[:szA |
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1340
        0 to:32 do:[:szB |
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1341
            |szAB|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1342
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1343
            strA := String new:szA withAll:$a.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1344
            strB := String new:szB withAll:$b.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1345
            szAB := szA + szB.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1346
            self assert:(szA = strA size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1347
            self assert:(szB = strB size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1348
            "/ why repeat ??? - to check GC???
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1349
            1 "10000" timesRepeat:[
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1350
                |strAB|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1351
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1352
                strAB := strA , strB.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1353
                self assert:(szAB == strAB size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1354
            ]
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1355
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1356
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1357
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1358
    strA := strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1359
    self assert: ((strA , strB) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1360
    self assert: ((strA , strA) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1361
    strA := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1362
    self assert: ((strA , strA) = 'aa').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1363
    self assert: ((strA , strB) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1364
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1365
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1366
    self assert: ((strA , strB) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1367
    strA := 'b'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1368
    strB := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1369
    self assert: ((strB , strA) = 'ab').
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1370
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1371
    "/ concatenating other things
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1372
    self assert:('hello',123) = 'hello123'.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1373
    self assert:('hello' asUnicode16String,123) = 'hello123' asUnicode16String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1374
    self assert:('hello' asUnicode32String,123) = 'hello123' asUnicode32String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1375
    
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1376
    "/ concatenating other things
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1377
    self assert:('hello',,123) = c'hello\n123'.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1378
    self assert:('hello' asUnicode16String,,123) = c'hello\n123' asUnicode16String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1379
    self assert:('hello' asUnicode32String,,123) = c'hello\n123' asUnicode32String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1380
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1381
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1382
     self new test65_concatenation
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1383
    "
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1384
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1385
    "Modified: / 02-04-2019 / 10:41:24 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1386
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1387
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1388
test66_replace
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1389
    |strA|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1390
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1391
    1 to:64 do:[:szA |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1392
	strA := String new:szA withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1393
	    1 to:szA do:[:idx |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1394
		strA at:idx put:$*.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1395
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1396
		strA replaceAll:$* with:$#.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1397
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1398
		self assert:(strA at:idx) = $#.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1399
		self assert:(strA occurrencesOf:$#) = idx.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1400
		self assert:(strA count:[:ch | ch = $#]) = idx.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1401
		self assert:(strA occurrencesOf:$*) = 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1402
		self assert:(strA count:[:ch | ch = $*]) = 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1403
		self assert:(strA includes:$#).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1404
		self assert:(strA includes:$*) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1405
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1406
    ]
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1407
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1408
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1409
     self new test66_replace
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1410
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1411
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1412
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1413
test67_concatenationAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1414
    |strA strB strC|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1415
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1416
    0 to:32 do:[:szA |
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1417
        0 to:32 do:[:szB |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1418
            0 to:32 do:[:szC |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1419
                |szABC|
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1420
                strA := String new:szA withAll:$a.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1421
                strB := String new:szB withAll:$b.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1422
                strC := String new:szC withAll:$c.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1423
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1424
                szABC := szA + szB + szC.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1425
                self assert:(szA = strA size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1426
                self assert:(szB = strB size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1427
                self assert:(szC = strC size).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1428
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1429
                "/ why repeat? to test GC???
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1430
                1 "300" timesRepeat:[
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1431
                    |strABC|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1432
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1433
                    strABC := strA concatenate:strB and:strC.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1434
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1435
                    self assert:(szABC == strABC size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1436
                ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1437
            ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1438
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1439
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1440
    strA := strB := strC := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1441
    self assert: ((strA concatenate:strB and:strC) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1442
    strA := 'a'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1443
    self assert: ((strA concatenate:strB and:strC) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1444
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1445
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1446
    self assert: ((strA concatenate:strB and:strC) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1447
    strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1448
    strC := 'c'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1449
    self assert: ((strA concatenate:strB and:strC) = 'c').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1450
    strA := 'c'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1451
    strB := 'b'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1452
    strC := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1453
    self assert: ((strC concatenate:strB and:strA) = 'abc').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1454
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1455
     self new test67_concatenationAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1456
    "
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1457
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1458
    "Modified: / 02-04-2019 / 10:51:31 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1459
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1460
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1461
test68_concatenationAndAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1462
    |strA strB strC strD|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1463
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1464
    0 to:32 do:[:szA |
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1465
        strA := String new:szA withAll:$a.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1466
        self assert:(szA = strA size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1467
        0 to:32 do:[:szB |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1468
            strB := String new:szB withAll:$b.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1469
            self assert:(szB = strB size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1470
            0 to:32 do:[:szC |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1471
                strC := String new:szC withAll:$c.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1472
                self assert:(szC = strC size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1473
                0 to:32 do:[:szD |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1474
                    |szABCD|
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1475
                    strD := String new:szD withAll:$d.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1476
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1477
                    szABCD := szA + szB + szC + szD.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1478
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1479
                    self assert:(szD = strD size).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1480
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1481
                    "/ why repeat???
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1482
                    1 "5" timesRepeat:[
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1483
                        |strABCD|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1484
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1485
                        strABCD := strA concatenate:strB and:strC and:strD.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1486
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1487
                        self assert:(szABCD == strABCD size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1488
                    ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1489
                ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1490
            ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1491
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1492
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1493
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1494
    strA := strB := strC := strD := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1495
    self assert: ((strA concatenate:strB and:strC and:strD) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1496
    strA := 'a'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1497
    self assert: ((strA concatenate:strB and:strC and:strD) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1498
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1499
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1500
    self assert: ((strA concatenate:strB and:strC and:strD) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1501
    strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1502
    strC := 'c'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1503
    self assert: ((strA concatenate:strB and:strC and:strD) = 'c').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1504
    strC := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1505
    strD := 'd'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1506
    self assert: ((strA concatenate:strB and:strC and:strD) = 'd').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1507
    strA := 'd'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1508
    strB := 'c'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1509
    strC := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1510
    strD := 'a'.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1511
    self assert: ((strD concatenate:strC and:strB and:strA) = 'abcd').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1512
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1513
     self new test68_concatenationAndAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1514
    "
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1515
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1516
    "Modified: / 02-04-2019 / 10:51:50 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1517
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1518
1991
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1519
test69_split
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1520
    self assert:(('a,b,c,d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1521
    self assert:(('a;b;c;d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1522
    self assert:(('a;b,c;d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1523
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1524
    self assert:(($, split:'a,b,c,d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1525
    self assert:((',' split:'a,b,c,d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1526
    self assert:(('//' split:'a//b//c//d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1527
    self assert:(('a//b//c//d' splitOn:'//') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1528
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1529
    "/ self assert:(([:ch | ch isLetter] split:'a2b3c4') sameContentsAs: #('1' '2' '3' '4')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1530
    "/ self assert:(([:char | char isDigit] split: '1a2b3c4') sameContentsAs: #('a' 'b' 'c')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1531
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1532
    "
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1533
     self new test69_split
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1534
    "
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1535
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1536
    "Created: / 20-07-2018 / 23:54:15 / Claus Gittinger"
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1537
!
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1538
962
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1539
test70_storeString
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1540
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1541
    self assert: 'AAA' storeString = '''AAA'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1542
    self assert: 'A''A''A' storeString = '''A''''A''''A'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1543
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1544
    self assert: 'AAA' asImmutableString storeString = '''AAA'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1545
    self assert: 'A''A''A' asImmutableString storeString = '''A''''A''''A'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1546
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1547
    "Created: / 14-07-2013 / 19:17:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1103
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1548
!
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1549
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1550
test80_copyReplaceAll
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1551
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1552
    | orig copy |
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1553
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1554
    orig := 'AAA' copy. "/ In case literals are immutable...
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1555
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1556
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1557
    copy := orig copyReplaceAll: $A with: $X.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1558
    self assert: copy = 'XXX'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1559
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1560
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1561
    orig := 'AAA' asImmutableString.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1562
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1563
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1564
    copy := orig copyReplaceAll: $A with: $X.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1565
    self assert: copy = 'XXX'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1566
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1567
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1568
    "Created: / 06-03-2014 / 15:10:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1569
!
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1570
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1571
test81_filling
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1572
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1573
    | str |
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1574
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1575
    str := 'AAA' copy. "/ In case literals are immutable...
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1576
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1577
    str atAllPut:$B.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1578
    self assert: str = 'BBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1579
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1580
    str from:1 to:0 put:$C.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1581
    self assert: str = 'BBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1582
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1583
    str from:1 to:1 put:$D.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1584
    self assert: str = 'DBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1585
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1586
    str from:1 to:2 put:$E.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1587
    self assert: str = 'EEB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1588
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1589
    str from:1 to:3 put:$F.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1590
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1591
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1592
    str from:1 to:0 put:$G.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1593
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1594
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1595
    str from:-1 to:-2 put:$G.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1596
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1597
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1598
    self should:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1599
	str from:-1 to:-1 put:$x
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1600
    ] raise:SubscriptOutOfBoundsError.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1601
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1602
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1603
    self should:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1604
	str from:-1 to:1 put:$x
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1605
    ] raise:SubscriptOutOfBoundsError.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1606
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1607
!
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1608
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1609
test82a_expanding
2077
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1610
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1611
    | rslt |
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1612
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1613
    rslt := 'A%1B%2C' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1614
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1615
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1616
    rslt := 'A%1B%2C%' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1617
    self assert:(rslt = 'A10B20C%').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1618
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1619
    rslt := 'A%%1B%2C%' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1620
    self assert:(rslt = 'A%1B20C%').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1621
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1622
    
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1623
    rslt := 'A%aB%bC' expandPlaceholdersWith:(Dictionary withKeys:#(a b c)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1624
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1625
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1626
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1627
    "/ not expanded, if not found
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1628
    rslt := 'A%aB%bC' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1629
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1630
    self assert:(rslt = 'A%aB%bC').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1631
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1632
    rslt := 'A%aaB%bbC' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1633
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1634
    self assert:(rslt = 'A%aaB%bbC').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1635
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1636
    rslt := 'A%(aa)B%(bb)C' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1637
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1638
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1639
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1640
    "/ allowing non-parenthized 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1641
    rslt := String streamContents:[:s |
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1642
                'A%aa,B%bb,C' 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1643
                        expandPlaceholders:$%
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1644
                        with:(Dictionary withKeys:#(aa bb cc) andValues:#(10 20 30))
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1645
                        ignoreNumericEscapes:false 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1646
                        requireParentheses:false
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1647
                        on:s.
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1648
            ].
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1649
    self assert:(rslt = 'A10,B20,C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1650
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1651
    "Created: / 02-04-2019 / 11:00:08 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1652
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1653
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1654
test82b_expanding
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1655
    | rslt |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1656
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1657
    rslt := 'hello' copyExpanding:(Dictionary 
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1658
                                        withKeys:{$h . $e . $o} 
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1659
                                        andValues:{'HH' . 'EE' . $O }).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1660
    self assert:(rslt = 'HHEEllO').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1661
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1662
    rslt := 'he%2llo%1' % { 123 . 456 }.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1663
    self assert:(rslt = 'he456llo123').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1664
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1665
    "Created: / 02-04-2019 / 11:00:43 / Claus Gittinger"
2077
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1666
!
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1667
2112
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1668
test83_padding
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1669
    | rslt |
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1670
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1671
    rslt := 'foo' paddedTo:10.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1672
    self assert:(rslt = 'foo       ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1673
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1674
    rslt := 'foo' paddedTo:3.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1675
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1676
    rslt := 'foo' paddedTo:4.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1677
    self assert:(rslt = 'foo ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1678
    rslt := 'foo' paddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1679
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1680
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1681
    rslt := '' paddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1682
    self assert:(rslt = '  ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1683
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1684
    rslt := 'foo' paddedTo:10 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1685
    self assert:(rslt = 'foo-------').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1686
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1687
    rslt := 'foo' paddedTo:3 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1688
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1689
    rslt := 'foo' paddedTo:4 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1690
    self assert:(rslt = 'foo-').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1691
    rslt := 'foo' paddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1692
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1693
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1694
    rslt := '' paddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1695
    self assert:(rslt = '--').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1696
    
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1697
    rslt := 'foo' leftPaddedTo:10.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1698
    self assert:(rslt = '       foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1699
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1700
    rslt := 'foo' leftPaddedTo:3.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1701
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1702
    rslt := 'foo' leftPaddedTo:4.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1703
    self assert:(rslt = ' foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1704
    rslt := 'foo' leftPaddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1705
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1706
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1707
    rslt := '' leftPaddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1708
    self assert:(rslt = '  ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1709
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1710
    rslt := 'foo' leftPaddedTo:10 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1711
    self assert:(rslt = '-------foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1712
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1713
    rslt := 'foo' leftPaddedTo:3 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1714
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1715
    rslt := 'foo' leftPaddedTo:4 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1716
    self assert:(rslt = '-foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1717
    rslt := 'foo' leftPaddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1718
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1719
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1720
    rslt := '' leftPaddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1721
    self assert:(rslt = '--').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1722
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1723
    "Created: / 21-03-2019 / 12:58:33 / Claus Gittinger"
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1724
!
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  1725
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1726
test84_withCRs
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1727
    | rslt |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1728
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1729
    rslt := 'foo\bar' addLineDelimiters.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1730
    self assert:(rslt = ('foo',Character cr,'bar')).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1731
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1732
    "Created: / 02-04-2019 / 10:57:44 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1733
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1734
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1735
test90_hash
2208
2d54a6ac9a73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  1736
    "all string-representations must hash equal"
2d54a6ac9a73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  1737
    
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1738
    | string8 string16 string32 |
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1739
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1740
    string8 := 'sun/nio/cs/UTF_8.class'.
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1741
    string16 := string8 asUnicode16String.
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1742
    string32 := string8 asUnicode16String.
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1743
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1744
    self assert: string8 hash == string16 hash.
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1745
    self assert: string8 hash == string32 hash.
2208
2d54a6ac9a73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  1746
    self assert: string8 hash == string8 asSymbol hash.
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1747
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1748
    "Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2208
2d54a6ac9a73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  1749
    "Modified: / 02-04-2019 / 10:42:35 / Claus Gittinger"
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
! !
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
!StringTests class methodsFor:'documentation'!
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
version
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
    ^ '$Header$'
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1756
!
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1757
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1758
version_CVS
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  1759
    ^ '$Header$'
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
! !
752
ef9236c7271c class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 751
diff changeset
  1761