author | convert-repo |
Thu, 08 Dec 2016 04:53:03 +0000 | |
changeset 1563 | bcbe9f1e2bba |
parent 1447 | 2351db93aa5b |
child 1500 | d406a10b2965 |
child 1693 | 04a3687c829e |
permissions | -rw-r--r-- |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
283 | 2 |
|
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#StringTests |
|
1421 | 6 |
instanceVariableNames:'' |
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'tests-Regression-Collections' |
|
283 | 10 |
! |
11 |
||
12 |
||
1425 | 13 |
!StringTests class methodsFor:'queries'! |
14 |
||
15 |
coveredClassNames |
|
16 |
"should be redefined to return a collection of classes which are tested by |
|
1447 | 17 |
this suite/case. |
1425 | 18 |
If not redefined, coveredPackageNames should be. |
19 |
||
20 |
These classes can be instrumented for coverage analysis, |
|
21 |
before running the suite to provide coverage analysis/report" |
|
22 |
||
23 |
^ #( String CharacterArray ) |
|
24 |
||
25 |
"Created: / 06-07-2011 / 21:27:03 / cg" |
|
26 |
! ! |
|
27 |
||
288 | 28 |
!StringTests methodsFor:'helpers'! |
284 | 29 |
|
288 | 30 |
runAccessTestsOnInstancesOf:aStringClass |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
31 |
|str s0 s1 s2 s3 s4 t| |
284 | 32 |
|
33 |
0 to:33 do:[:l | |
|
1447 | 34 |
str := aStringClass new:l. |
35 |
str atAllPut:(Character space). |
|
36 |
self assert:( str isBlank ). |
|
284 | 37 |
|
1447 | 38 |
1 to:l do:[:pos | |
39 |
str at:pos put:$a. |
|
40 |
self assert:( str isBlank not ). |
|
41 |
str at:pos put:(Character space). |
|
42 |
]. |
|
284 | 43 |
]. |
44 |
||
288 | 45 |
s0 := aStringClass new:0. |
287 | 46 |
self assert:s0 isEmpty. |
47 |
self assert:s0 isEmptyOrNil. |
|
48 |
self assert:s0 size == 0. |
|
49 |
||
288 | 50 |
s1 := (aStringClass new:5) replaceFrom:1 with:'hello'. |
51 |
s2 := (aStringClass new:6) replaceFrom:1 with:' world'. |
|
285 | 52 |
self assert:(s1 , s2) size == 11. |
288 | 53 |
self assert:(s1 , s2) class == aStringClass. |
285 | 54 |
self assert:(s1 = 'hello'). |
55 |
self assert:(s2 = ' world'). |
|
56 |
self assert:(s1 size == 5). |
|
57 |
self assert:(s2 size == 6). |
|
288 | 58 |
|
285 | 59 |
self assert:(s1 = 'hello'). |
60 |
self assert:(s1 asSymbol == #'hello'). |
|
61 |
self assert:(s1 copyFrom:1) = 'hello'. |
|
288 | 62 |
self assert:(s1 copyFrom:1) class == aStringClass. |
285 | 63 |
self assert:(s1 copyFrom:1 to:3) = 'hel'. |
288 | 64 |
self assert:(s1 copyFrom:1 to:3) class == aStringClass. |
285 | 65 |
self assert:(s1 copyWith:$X) = 'helloX'. |
288 | 66 |
self assert:(s1 copyWith:$X) class == aStringClass. |
285 | 67 |
self assert:(s1 endsWith:'llo'). |
68 |
self assert:(s1 startsWith:'hel'). |
|
286 | 69 |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
70 |
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
|
71 |
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
|
72 |
self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t). |
288 | 73 |
|
74 |
self assert:(s1 identityIndexOf:$h startingAt:1) == 1. |
|
75 |
self assert:(s1 identityIndexOf:$h startingAt:2) == 0. |
|
76 |
self assert:(s1 identityIndexOf:$e startingAt:1) == 2. |
|
77 |
self assert:(s1 identityIndexOf:$e startingAt:2) == 2. |
|
78 |
self assert:(s1 identityIndexOf:$l startingAt:1) == 3. |
|
79 |
self assert:(s1 identityIndexOf:$l startingAt:2) == 3. |
|
80 |
self assert:(s1 identityIndexOf:$l startingAt:3) == 3. |
|
81 |
self assert:(s1 identityIndexOf:$l startingAt:4) == 4. |
|
82 |
self assert:(s1 identityIndexOf:$l startingAt:5) == 0. |
|
83 |
self assert:(s1 identityIndexOf:$l startingAt:6) == 0. |
|
84 |
||
286 | 85 |
self assert:(s1 indexOf:$h) == 1. |
86 |
self assert:(s1 indexOf:$l) == 3. |
|
287 | 87 |
self assert:(s1 indexOf:$L) == 0. |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
88 |
self assert:(s1 indexOf:$A) == 0. |
288 | 89 |
|
286 | 90 |
self assert:(s1 indexOf:$h startingAt:1) == 1. |
91 |
self assert:(s1 indexOf:$h startingAt:2) == 0. |
|
92 |
self assert:(s1 indexOf:$e startingAt:1) == 2. |
|
93 |
self assert:(s1 indexOf:$e startingAt:2) == 2. |
|
94 |
self assert:(s1 indexOf:$l startingAt:1) == 3. |
|
95 |
self assert:(s1 indexOf:$l startingAt:2) == 3. |
|
96 |
self assert:(s1 indexOf:$l startingAt:3) == 3. |
|
97 |
self assert:(s1 indexOf:$l startingAt:4) == 4. |
|
98 |
self assert:(s1 indexOf:$l startingAt:5) == 0. |
|
99 |
self assert:(s1 indexOf:$l startingAt:6) == 0. |
|
288 | 100 |
|
286 | 101 |
self assert:(s1 includes:$l). |
102 |
self assert:(s1 includes:$L) not. |
|
288 | 103 |
|
287 | 104 |
self assert:(s1 includesAny:'a') not. |
105 |
self assert:(s1 includesAny:'ab') not. |
|
106 |
self assert:(s1 includesAny:'abc') not. |
|
107 |
self assert:(s1 includesAny:'abcd') not. |
|
108 |
self assert:(s1 includesAny:'abcde'). |
|
109 |
self assert:(s1 includesAny:'e'). |
|
110 |
self assert:(s1 includesAny:'ae'). |
|
111 |
self assert:(s1 includesAny:'ea'). |
|
112 |
self assert:(s1 includesAny:'abe'). |
|
113 |
self assert:(s1 includesAny:'eab'). |
|
114 |
self assert:(s1 includesAny:'aeb'). |
|
115 |
self assert:(s1 includesAny:'abce'). |
|
116 |
self assert:(s1 includesAny:'eabc'). |
|
117 |
self assert:(s1 includesAny:'aebc'). |
|
118 |
self assert:(s1 includesAny:'abec'). |
|
119 |
self assert:(s1 includesAny:'abcde'). |
|
1447 | 120 |
" 12345678901234567890 " |
288 | 121 |
s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'. |
122 |
t := s3 asCollectionOfSubstringsSeparatedBy:$,. |
|
123 |
self assert:(t size = 2). |
|
124 |
self assert:(t first = '12 45'). |
|
125 |
self assert:(t second = '78;01.34-67+90'). |
|
126 |
||
127 |
t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '. |
|
128 |
self assert:(t size = 5). |
|
129 |
self assert:(t first = '12'). |
|
130 |
self assert:(t second = '45'). |
|
131 |
self assert:(t third = '78'). |
|
132 |
self assert:(t fourth = '01'). |
|
133 |
self assert:(t fifth = '34-67+90'). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
134 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
135 |
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
|
136 |
self assert:(s4 size = 10). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
137 |
self assert:(s4 indexOfSeparatorStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
138 |
self assert:(s4 indexOfSeparatorStartingAt:3) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
139 |
self assert:(s4 indexOfSeparatorStartingAt:4) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
140 |
self assert:(s4 indexOfSeparatorStartingAt:5) = 8. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
141 |
self assert:(s4 indexOfControlCharacterStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
142 |
self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
143 |
self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
144 |
self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
145 |
self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5. |
352 | 146 |
! ! |
147 |
||
148 |
!StringTests methodsFor:'tests'! |
|
288 | 149 |
|
150 |
test01_access |
|
151 |
0 to:33 do:[:l | |
|
1447 | 152 |
|str| |
288 | 153 |
|
1447 | 154 |
str := String new:l. |
155 |
str atAllPut:(Character space). |
|
156 |
self assert:( str isBlank ). |
|
157 |
self assert:((str size == 0) or: [(str first) == Character space.]). |
|
288 | 158 |
|
1447 | 159 |
1 to:l do:[:pos | |
160 |
str at:pos put:$a. |
|
161 |
self assert:( str isBlank not ). |
|
162 |
self assert:((str at:pos) == $a). |
|
163 |
str at:pos put:(Character space). |
|
164 |
]. |
|
288 | 165 |
]. |
166 |
self runAccessTestsOnInstancesOf:String |
|
167 |
||
168 |
" |
|
169 |
self new test01_access |
|
170 |
" |
|
171 |
! |
|
172 |
||
173 |
test02_subclassAccess |
|
174 |
|myStringClass s1| |
|
175 |
||
176 |
Class withoutUpdatingChangesDo:[ |
|
1421 | 177 |
myStringClass := String |
178 |
subclass:#'MyString' |
|
179 |
instanceVariableNames:'foo' |
|
180 |
classVariableNames:'' |
|
181 |
poolDictionaries:nil. |
|
182 |
myStringClass compile:'foo ^foo'. |
|
183 |
myStringClass compile:'foo:arg foo := arg'. |
|
288 | 184 |
]. |
185 |
||
186 |
s1 := (myStringClass new:5) replaceFrom:1 with:'hello'. |
|
187 |
self assert:(s1 foo isNil). |
|
188 |
self assert:(s1 size == 5). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
189 |
s1 foo:16r11413344. "/ ensure there is a $A inside (hex 41) |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
190 |
self assert:(s1 foo == 16r11413344). |
288 | 191 |
self assert:(s1 = 'hello'). |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
192 |
self assert:(s1 deepCopy foo == 16r11413344). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
193 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
194 |
self assert:((s1 indexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
195 |
self assert:((s1 identityIndexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
196 |
self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A |
288 | 197 |
|
198 |
self runAccessTestsOnInstancesOf:myStringClass. |
|
285 | 199 |
|
284 | 200 |
" |
201 |
self new test02_subclassAccess |
|
202 |
" |
|
203 |
! |
|
204 |
||
205 |
test10_Contains8BitCharacters |
|
288 | 206 |
0 to:65 do:[:l | |
1421 | 207 |
|str| |
283 | 208 |
|
1421 | 209 |
str := String new:l. |
210 |
str atAllPut:(Character value:16r7F). |
|
211 |
self assert:( str contains8BitCharacters not ). |
|
283 | 212 |
|
1421 | 213 |
1 to:l do:[:pos | |
214 |
str at:pos put:(Character value:16r80). |
|
215 |
self assert:( str contains8BitCharacters ). |
|
216 |
str at:pos put:(Character value:16r7F). |
|
217 |
]. |
|
283 | 218 |
]. |
219 |
||
220 |
" |
|
284 | 221 |
self new test10_Contains8BitCharacters |
283 | 222 |
" |
288 | 223 |
! |
224 |
||
1426 | 225 |
test11_IsEmpty |
226 |
|nul n| |
|
227 |
nul := 0 asCharacter. |
|
228 |
n := 1. |
|
229 |
self assert:('' isEmpty). |
|
230 |
self assert:(' ' isEmpty not). |
|
231 |
self assert:(nul asCharacter asString isEmpty not). |
|
232 |
self assert:(('' , nul) isEmpty not). |
|
233 |
self assert:((String new:0) isEmpty). |
|
234 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
235 |
||
1447 | 236 |
29 timesRepeat:[ |
237 |
|s| |
|
1426 | 238 |
|
1447 | 239 |
s := String new:(n + 17). |
240 |
self assert:(s isEmpty not). |
|
241 |
n := n * 2. |
|
1426 | 242 |
]. |
243 |
self assert:((String new:17 withAll:nul) isEmpty not). |
|
244 |
self assert:((String new:0 withAll:nul) isEmpty). |
|
245 |
" |
|
1429 | 246 |
self new test11_IsEmpty |
247 |
" |
|
1426 | 248 |
! |
249 |
||
250 |
test12_Comparison |
|
251 |
0 to: 255 do: [ :i | |
|
1447 | 252 |
|s t| |
1426 | 253 |
|
1447 | 254 |
1 to: 9 do: [ :j | |
255 |
s := String new:j withAll:(i asCharacter). |
|
256 |
t := s copy. |
|
1426 | 257 |
|
1447 | 258 |
self assert:(s notNil). |
259 |
self assert:(s = s). |
|
260 |
self assert:(s ~= s) not. |
|
261 |
self assert:(s < s) not. |
|
262 |
self assert:(s > s) not. |
|
263 |
self assert:(s = (s,s)) not. |
|
1426 | 264 |
|
1447 | 265 |
self assert:(t notNil). |
266 |
self assert:(s = t). |
|
267 |
self assert:(s ~= t) not. |
|
268 |
self assert:(s < t) not. |
|
269 |
self assert:(s > t) not. |
|
1426 | 270 |
|
1447 | 271 |
self assert:((s = nil) == ((s ~= nil) not)). |
272 |
self assert:((s = '') == ((s ~= '') not)). |
|
273 |
]. |
|
1426 | 274 |
|
1447 | 275 |
s := i asCharacter asString. |
276 |
0 to: 255 do: [ :j | |
|
277 |
t := j asCharacter asString. |
|
278 |
self assert:(t notNil). |
|
1426 | 279 |
|
1447 | 280 |
self assert:((s = t) == ((s ~= t) not)). |
281 |
] |
|
1426 | 282 |
]. |
283 |
||
284 |
" |
|
285 |
self new test12_Comparison |
|
286 |
" |
|
287 |
! |
|
288 |
||
289 |
test15_CompareWithCollating |
|
290 |
| nul | |
|
291 |
||
292 |
nul := 0 asCharacter asString. |
|
293 |
self assert:('' compareWith:'' collating:true) == 0. |
|
294 |
self assert:('' compareWith:'' collating:false) == 0. |
|
1447 | 295 |
self assert:(nul compareWith:(255 asCharacter asString) collating:false) == -1. |
1426 | 296 |
self assert:((255 asCharacter asString) compareWith:nul collating:false) == 1. |
1433 | 297 |
"/ This will fail and is a WONTFIX |
298 |
"/ self assert:((('' compareWith:nul collating:false) == 0) == ('' = nul)). |
|
1426 | 299 |
|
300 |
0 to: 255 do: [ :i | |
|
1447 | 301 |
|s| |
1426 | 302 |
|
1447 | 303 |
s := i asCharacter asString. |
304 |
self assert:(s notNil). |
|
1426 | 305 |
|
1447 | 306 |
"/ This will fail and is a WONTFIX |
307 |
"/ self assert:('' compareWith:s collating:false) ~= 0. |
|
308 |
self assert:('' compareWith:s collating:false) == ((s compareWith:'' collating:false) negated). |
|
1426 | 309 |
|
1447 | 310 |
0 to: 255 do: [ :j | |
311 |
| t | |
|
312 |
t := j asCharacter asString. |
|
313 |
self assert:(t notNil). |
|
1426 | 314 |
|
1447 | 315 |
self assert:(((s compareWith:t collating:false) == -1) == (s < t)). |
316 |
self assert:(((s compareWith:t collating:false) == 0) == (s = t)). |
|
317 |
self assert:(((s compareWith:t collating:false) == 1) == (s > t)). |
|
318 |
self assert:(((s compareWith:t collating:true) == -1) == (s < t)). |
|
319 |
self assert:(((s compareWith:t collating:true) == 0) == (s = t)). |
|
320 |
self assert:(((s compareWith:t collating:true) == 1) == (s > t)). |
|
321 |
] |
|
1426 | 322 |
]. |
323 |
||
324 |
0 to: 9 do: [ :i | |
|
1447 | 325 |
0 to: 255 do: [ :j | |
326 |
|s t| |
|
327 |
s := String new:i withAll:(j asCharacter). |
|
328 |
t := s copy. |
|
1426 | 329 |
|
1447 | 330 |
self assert: (s compareWith:s collating:false) == 0. |
331 |
self assert: (s compareWith:s collating:true) == 0. |
|
332 |
self assert: (s compareWith:t collating:false) == 0. |
|
333 |
self assert: (s compareWith:t collating:true) == 0 |
|
334 |
] |
|
1426 | 335 |
]. |
336 |
||
337 |
" |
|
338 |
self new test15_CompareWithCollating |
|
339 |
" |
|
340 |
! |
|
341 |
||
288 | 342 |
test20_literalsAreReadonly |
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
343 |
|myClass s1 l2 s2 parserFlags compiler| |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
344 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
345 |
parserFlags := Compiler new parserFlags copy. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
346 |
parserFlags stringsAreImmutable:true. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
347 |
parserFlags arraysAreImmutable:true. |
288 | 348 |
|
349 |
Class withoutUpdatingChangesDo:[ |
|
1421 | 350 |
myClass := Object |
351 |
subclass:#'MyClass' |
|
352 |
instanceVariableNames:'' |
|
353 |
classVariableNames:'' |
|
354 |
poolDictionaries:nil. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
355 |
|
1421 | 356 |
compiler := myClass compilerClass new. |
357 |
compiler parserFlags:parserFlags. |
|
358 |
compiler compile:'lit1 ^''hello''' forClass:myClass install:true. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
359 |
|
1421 | 360 |
compiler := myClass compilerClass new. |
361 |
compiler parserFlags:parserFlags. |
|
362 |
compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true. |
|
288 | 363 |
]. |
364 |
||
365 |
s1 := myClass new perform:#lit1. |
|
366 |
self assert:(s1 isString). |
|
367 |
self assert:(s1 class == ImmutableString). |
|
368 |
self should:[ s1 at:1 put:$H ] raise:Error. |
|
369 |
||
370 |
l2 := myClass new perform:#lit2. |
|
371 |
self assert:(l2 isArray). |
|
372 |
self assert:(l2 class == ImmutableArray). |
|
373 |
self should:[ l2 at:1 put:$H ] raise:Error. |
|
374 |
s2 := l2 at:1. |
|
375 |
self assert:(s2 isString). |
|
376 |
self assert:(s2 class == ImmutableString). |
|
377 |
self should:[ s2 at:1 put:$H ] raise:Error. |
|
378 |
||
379 |
" |
|
380 |
self new test20_literalsAreReadonly |
|
381 |
" |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
382 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
383 |
"Modified: / 02-08-2011 / 19:30:53 / cg" |
352 | 384 |
! |
385 |
||
1418 | 386 |
test30_indexOfSubCollection |
352 | 387 |
|i| |
388 |
"/ 12345678901 |
|
389 |
i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
390 |
self assert:(i == 7). |
|
391 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
392 |
self assert:(i == 0). |
|
393 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
394 |
self assert:(i == 7). |
|
395 |
i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
396 |
self assert:(i == 3). |
|
397 |
||
398 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
399 |
self assert:(i == 3). |
|
400 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false. |
|
401 |
self assert:(i == 3). |
|
402 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false. |
|
403 |
self assert:(i == 15). |
|
404 |
||
353 | 405 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false. |
406 |
self assert:(i == 16). |
|
407 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false. |
|
408 |
self assert:(i == 0). |
|
409 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false. |
|
410 |
self assert:(i == 0). |
|
411 |
||
352 | 412 |
" |
1418 | 413 |
self new test30_indexOfSubCollection |
352 | 414 |
" |
570 | 415 |
! |
416 |
||
417 |
test40_indexOfAny |
|
1426 | 418 |
|s i collection| |
570 | 419 |
|
420 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
421 |
1 to:s size do:[:start | |
|
1447 | 422 |
i := s indexOfAny:'-' startingAt:start. |
423 |
self assert:(i == 0 or:[ i >= start]). |
|
424 |
(i ~~ 0) ifTrue:[ |
|
425 |
self assert:(s at:i) == $- |
|
426 |
]. |
|
1308 | 427 |
]. |
1447 | 428 |
"/ 123456789012 |
1308 | 429 |
s := 'bla bla 1234'. |
430 |
1 to:s size do:[:start | |
|
1447 | 431 |
i := s indexOfAny:'1234' startingAt:start. |
432 |
self assert:(i == 0 or:[ i >= start]). |
|
433 |
(i == 9) ifTrue:[ self assert:((s at:i) == $1) ]. |
|
434 |
(i == 10) ifTrue:[ self assert:((s at:i) == $2) ]. |
|
435 |
(i == 11) ifTrue:[ self assert:((s at:i) == $3) ]. |
|
436 |
(i == 12) ifTrue:[ self assert:((s at:i) == $4) ]. |
|
570 | 437 |
]. |
438 |
||
1426 | 439 |
collection := #($o, $l, $o). |
440 |
"/ 12345678901 |
|
441 |
i := 'hello world' indexOfAny:collection startingAt:1. |
|
442 |
self assert:(i == 3). |
|
443 |
i := 'hello world' indexOfAny:collection startingAt:2. |
|
444 |
self assert:(i == 3). |
|
445 |
i := 'hello world' indexOfAny:collection startingAt:3. |
|
1447 | 446 |
self assert:(i == 3). |
1426 | 447 |
i := 'hello world' indexOfAny:collection startingAt:4. |
1447 | 448 |
self assert:(i == 4). |
1426 | 449 |
i := 'hello world' indexOfAny:collection startingAt:5. |
1447 | 450 |
self assert:(i == 5). |
1426 | 451 |
i := 'hello world' indexOfAny:collection startingAt:6. |
1447 | 452 |
self assert:(i == 8). |
1426 | 453 |
i := 'hello world' indexOfAny:collection startingAt:7. |
454 |
self assert:(i == 8). |
|
455 |
i := 'hello world' indexOfAny:collection startingAt:8. |
|
1447 | 456 |
self assert:(i == 8). |
1426 | 457 |
i := 'hello world' indexOfAny:collection startingAt:9. |
1447 | 458 |
self assert:(i == 10). |
1426 | 459 |
i := 'hello world' indexOfAny:collection startingAt:10. |
1447 | 460 |
self assert:(i == 10). |
1426 | 461 |
i := 'hello world' indexOfAny:collection startingAt:11. |
462 |
self assert:(i == 0). |
|
463 |
i := 'hello world' indexOfAny:collection startingAt:12. |
|
464 |
self assert:(i == 0). |
|
465 |
i := 'hello world' indexOfAny:collection startingAt:10000. |
|
466 |
self assert:(i == 0). |
|
570 | 467 |
" |
468 |
self new test40_indexOfAny |
|
469 |
" |
|
470 |
||
471 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
571 | 472 |
! |
473 |
||
1308 | 474 |
test41_contains |
475 |
|s| |
|
476 |
||
477 |
s := 'abcdefg'. |
|
478 |
self assert:(s contains:[:ch | ch == $a]). |
|
479 |
self assert:(s contains:[:ch | ch == $A]) not. |
|
480 |
self assert:(s contains:[:ch | ch == $1]) not. |
|
1426 | 481 |
self assert:(s contains:[:ch | ch == (0 asCharacter)]) not. |
1308 | 482 |
" |
483 |
self new test41_contains |
|
484 |
" |
|
485 |
! |
|
486 |
||
1420 | 487 |
test42_includesAny |
488 |
|s| |
|
489 |
||
490 |
1 to:20 do:[:na | |
|
1447 | 491 |
s := (String new:na withAll:$a),'bla bla 1234'. |
492 |
self assert:( s includesAny:'12'). |
|
493 |
self assert:( s includesAny:'21'). |
|
494 |
self assert:( s includesAny:'15'). |
|
495 |
self assert:( s includesAny:'51'). |
|
496 |
self assert:( s includesAny:'45'). |
|
497 |
self assert:( s includesAny:'54'). |
|
498 |
self assert:( s includesAny:'56') not. |
|
1420 | 499 |
]. |
1447 | 500 |
|
1420 | 501 |
" |
502 |
self new test42_includesAny |
|
503 |
" |
|
1421 | 504 |
! |
1420 | 505 |
|
1421 | 506 |
test43_occurrencesOf |
1418 | 507 |
|s| |
508 |
||
509 |
"/ 12345678901 |
|
510 |
self assert:( 'hello world' occurrencesOf:$0 ) == 0. |
|
1447 | 511 |
self assert:( 'hello world' occurrencesOf:$l ) == 3. |
512 |
self assert:( 'hello world' occurrencesOf:$d ) == 1. |
|
1418 | 513 |
|
514 |
"/ how about 0-bytes in between |
|
515 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1. |
|
516 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4. |
|
517 |
||
518 |
1 to:10 do:[:nA | |
|
1447 | 519 |
1 to:10 do:[:nB | |
520 |
s := (String new:nA withAll:$a),(String new:nB withAll:$b). |
|
521 |
self assert:(s occurrencesOf:$a) == nA. |
|
522 |
self assert:(s occurrencesOf:$b) == nB. |
|
523 |
] |
|
524 |
]. |
|
1418 | 525 |
|
526 |
s := String new:1024. |
|
527 |
s atAllPut:$a. |
|
528 |
s at:512 put:(Character space). |
|
529 |
self assert:(s occurrencesOf:(Character space)) == 1. |
|
530 |
self assert:(s occurrencesOf:$a) == 1023. |
|
531 |
||
532 |
s := String new:1024. |
|
533 |
s atAllPut:$a. |
|
534 |
1 to:1024 by:2 do:[:i | s at:i put:$b]. |
|
535 |
self assert:(s occurrencesOf:$a) == 512. |
|
536 |
self assert:(s occurrencesOf:$b) == 512. |
|
1421 | 537 |
|
1418 | 538 |
" |
1421 | 539 |
self new test43_occurrencesOf |
1418 | 540 |
" |
541 |
! |
|
542 |
||
571 | 543 |
test50_indexOf |
544 |
|s i| |
|
545 |
||
546 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
547 |
1 to:s size do:[:start | |
|
1447 | 548 |
i := s indexOf:$- startingAt:start. |
549 |
self assert:(i == 0 or:[ i >= start]). |
|
571 | 550 |
]. |
1418 | 551 |
"/ 12345678901 |
552 |
self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0. |
|
1447 | 553 |
self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3. |
554 |
self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10. |
|
555 |
self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11. |
|
1418 | 556 |
|
1426 | 557 |
"/ 12345678901 |
558 |
self assert:(('hello world' indexOf:$o startingAt:1) == 5). |
|
559 |
self assert:(('hello world' indexOf:$o startingAt:2) == 5). |
|
560 |
self assert:(('hello world' indexOf:$o startingAt:3) == 5). |
|
561 |
self assert:(('hello world' indexOf:$o startingAt:4) == 5). |
|
562 |
self assert:(('hello world' indexOf:$o startingAt:5) == 5). |
|
563 |
self assert:(('hello world' indexOf:$o startingAt:6) == 8). |
|
564 |
self assert:(('hello world' indexOf:$o startingAt:7) == 8). |
|
565 |
self assert:(('hello world' indexOf:$o startingAt:8) == 8). |
|
566 |
self assert:(('hello world' indexOf:$o startingAt:9) == 0). |
|
567 |
self assert:(('hello world' indexOf:$o startingAt:10) == 0). |
|
568 |
self assert:(('hello world' indexOf:$o startingAt:11) == 0). |
|
569 |
self assert:(('hello world' indexOf:$o startingAt:12) == 0). |
|
570 |
self assert:(('hello world' indexOf:$o startingAt:10000) == 0). |
|
571 |
||
1418 | 572 |
"/ how about 0-bytes in between |
573 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3. |
|
574 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4. |
|
575 |
self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5. |
|
576 |
self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4. |
|
577 |
||
578 |
s := '12345678901234b'. |
|
579 |
self assert:(s indexOf:$x) == 0. |
|
580 |
self assert:(s indexOf:$1) == 1. |
|
581 |
self assert:(s indexOf:$2) == 2. |
|
582 |
self assert:(s indexOf:$3) == 3. |
|
583 |
self assert:(s indexOf:$4) == 4. |
|
584 |
self assert:(s indexOf:$5) == 5. |
|
585 |
self assert:(s indexOf:$0) == 10. |
|
586 |
self assert:(s indexOf:$b) == 15. |
|
587 |
||
588 |
s := ''. |
|
589 |
self assert:(s indexOf:$1) == 0. |
|
590 |
s := '1'. |
|
591 |
self assert:(s indexOf:$1) == 1. |
|
592 |
self assert:(s indexOf:$2) == 0. |
|
593 |
s := '12'. |
|
594 |
self assert:(s indexOf:$1) == 1. |
|
595 |
self assert:(s indexOf:$2) == 2. |
|
596 |
self assert:(s indexOf:$3) == 0. |
|
597 |
s := '123'. |
|
598 |
self assert:(s indexOf:$1) == 1. |
|
599 |
self assert:(s indexOf:$2) == 2. |
|
600 |
self assert:(s indexOf:$3) == 3. |
|
601 |
self assert:(s indexOf:$4) == 0. |
|
602 |
s := '1234'. |
|
603 |
self assert:(s indexOf:$1) == 1. |
|
604 |
self assert:(s indexOf:$2) == 2. |
|
605 |
self assert:(s indexOf:$3) == 3. |
|
606 |
self assert:(s indexOf:$4) == 4. |
|
607 |
self assert:(s indexOf:$5) == 0. |
|
608 |
s := '12345'. |
|
609 |
self assert:(s indexOf:$1) == 1. |
|
610 |
self assert:(s indexOf:$2) == 2. |
|
611 |
self assert:(s indexOf:$3) == 3. |
|
612 |
self assert:(s indexOf:$4) == 4. |
|
613 |
self assert:(s indexOf:$5) == 5. |
|
614 |
self assert:(s indexOf:$6) == 0. |
|
615 |
s := '123456'. |
|
616 |
self assert:(s indexOf:$1) == 1. |
|
617 |
self assert:(s indexOf:$2) == 2. |
|
618 |
self assert:(s indexOf:$3) == 3. |
|
619 |
self assert:(s indexOf:$4) == 4. |
|
620 |
self assert:(s indexOf:$5) == 5. |
|
621 |
self assert:(s indexOf:$6) == 6. |
|
622 |
self assert:(s indexOf:$7) == 0. |
|
623 |
s := '1234567'. |
|
624 |
self assert:(s indexOf:$1) == 1. |
|
625 |
self assert:(s indexOf:$2) == 2. |
|
626 |
self assert:(s indexOf:$3) == 3. |
|
627 |
self assert:(s indexOf:$4) == 4. |
|
628 |
self assert:(s indexOf:$5) == 5. |
|
629 |
self assert:(s indexOf:$6) == 6. |
|
630 |
self assert:(s indexOf:$7) == 7. |
|
631 |
self assert:(s indexOf:$8) == 0. |
|
632 |
s := '12345678'. |
|
633 |
self assert:(s indexOf:$1) == 1. |
|
634 |
self assert:(s indexOf:$2) == 2. |
|
635 |
self assert:(s indexOf:$3) == 3. |
|
636 |
self assert:(s indexOf:$4) == 4. |
|
637 |
self assert:(s indexOf:$5) == 5. |
|
638 |
self assert:(s indexOf:$6) == 6. |
|
639 |
self assert:(s indexOf:$7) == 7. |
|
640 |
self assert:(s indexOf:$8) == 8. |
|
641 |
self assert:(s indexOf:$9) == 0. |
|
642 |
s := '123456789'. |
|
643 |
self assert:(s indexOf:$1) == 1. |
|
644 |
self assert:(s indexOf:$2) == 2. |
|
645 |
self assert:(s indexOf:$3) == 3. |
|
646 |
self assert:(s indexOf:$4) == 4. |
|
647 |
self assert:(s indexOf:$5) == 5. |
|
648 |
self assert:(s indexOf:$6) == 6. |
|
649 |
self assert:(s indexOf:$7) == 7. |
|
650 |
self assert:(s indexOf:$8) == 8. |
|
651 |
self assert:(s indexOf:$9) == 9. |
|
652 |
||
653 |
self assert:(s indexOf:$0) == 0. |
|
654 |
self assert:(s indexOf:$b) == 0. |
|
655 |
||
656 |
s := String new:1024. |
|
657 |
s atAllPut:$a. |
|
658 |
s at:512 put:(Character space). |
|
659 |
self assert:(s indexOf:(Character space)) == 512. |
|
660 |
self assert:(s indexOf:(Character space) startingAt:1) == 512. |
|
661 |
self assert:(s indexOf:(Character space) startingAt:2) == 512. |
|
662 |
self assert:(s indexOf:(Character space) startingAt:3) == 512. |
|
663 |
self assert:(s indexOf:(Character space) startingAt:4) == 512. |
|
664 |
self assert:(s indexOf:(Character space) startingAt:5) == 512. |
|
665 |
self assert:(s indexOf:(Character space) startingAt:6) == 512. |
|
666 |
self assert:(s indexOf:(Character space) startingAt:7) == 512. |
|
667 |
self assert:(s indexOf:(Character space) startingAt:8) == 512. |
|
668 |
self assert:(s indexOf:(Character space) startingAt:9) == 512. |
|
669 |
self assert:(s indexOf:(Character space) startingAt:511) == 512. |
|
670 |
self assert:(s indexOf:(Character space) startingAt:512) == 512. |
|
671 |
self assert:(s indexOf:(Character space) startingAt:513) == 0. |
|
571 | 672 |
|
673 |
" |
|
674 |
self new test50_indexOf |
|
675 |
" |
|
676 |
||
677 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
678 |
! |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
679 |
|
1373 | 680 |
test51_substrings |
681 |
self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc'). |
|
682 |
self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'. |
|
683 |
||
1385 | 684 |
"/ self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc'). |
685 |
"/ self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'. |
|
686 |
"/ |
|
687 |
"/ self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ). |
|
688 |
"/ self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'. |
|
689 |
"/ |
|
690 |
"/ self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' ''). |
|
691 |
"/ self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '. |
|
692 |
"/ |
|
693 |
"/ self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc'). |
|
694 |
"/ self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'. |
|
1373 | 695 |
|
696 |
" |
|
697 |
self new test51_substrings |
|
698 |
" |
|
699 |
! |
|
700 |
||
1420 | 701 |
test52_indexOfSeparator |
1426 | 702 |
|j s| |
1420 | 703 |
|
704 |
self assert:('' indexOfSeparator) == 0. |
|
705 |
1 to:20 do:[:n | |
|
1447 | 706 |
s := (String new:n withAll:$a). |
707 |
1 to:20 do:[:start | |
|
708 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
709 |
]. |
|
710 |
]. |
|
1420 | 711 |
1 to:20 do:[:n | |
1447 | 712 |
s := (String new:n withAll:$a),' '. |
713 |
1 to:n do:[:start | |
|
714 |
self assert:(s indexOfSeparatorStartingAt:start) == (n+1). |
|
715 |
]. |
|
716 |
]. |
|
717 |
||
718 |
{ |
|
719 |
Character space . |
|
720 |
Character tab . |
|
721 |
Character return . |
|
722 |
Character lf . |
|
1420 | 723 |
} do:[:sep | |
1447 | 724 |
1 to:20 do:[:na | |
725 |
1 to:20 do:[:nb | |
|
726 |
s := (String new:na withAll:$a),sep,(String new:na withAll:$a). |
|
727 |
1 to:na do:[:start | |
|
728 |
self assert:(s indexOfSeparatorStartingAt:start) == (na+1). |
|
729 |
] |
|
730 |
] |
|
731 |
]. |
|
1420 | 732 |
]. |
1447 | 733 |
|
734 |
{ |
|
735 |
Character esc . |
|
736 |
Character null . |
|
737 |
$a . |
|
1420 | 738 |
} do:[:nonSep | |
1447 | 739 |
1 to:20 do:[:na | |
740 |
1 to:20 do:[:nb | |
|
741 |
s := (String new:na withAll:$a),nonSep,(String new:na withAll:$a). |
|
742 |
1 to:20 do:[:start | |
|
743 |
self assert:(s indexOfSeparatorStartingAt:start) == 0. |
|
744 |
] |
|
745 |
] |
|
746 |
]. |
|
1420 | 747 |
]. |
748 |
||
1426 | 749 |
s := String new:1000 withAll:$a. |
750 |
self assert:(s indexOfSeparatorStartingAt:1) == 0. |
|
751 |
400 to: 417 do:[:i | |
|
1447 | 752 |
s := String new:1000 withAll:$a. |
753 |
s at:i put:(Character space). |
|
754 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
1426 | 755 |
|
1447 | 756 |
s := String new:1000 withAll:$a. |
757 |
s at:i put:(Character return). |
|
758 |
self assert:(s indexOfSeparatorStartingAt:1) == i. |
|
759 |
]. |
|
1426 | 760 |
|
761 |
"/ 12345678901 |
|
762 |
j := 'hello world' indexOfSeparatorStartingAt:1. |
|
763 |
self assert:(j == 6). |
|
764 |
j := 'hello world ' indexOfSeparatorStartingAt:2. |
|
765 |
self assert:(j == 6). |
|
766 |
j := 'hello world ' indexOfSeparatorStartingAt:3. |
|
1447 | 767 |
self assert:(j == 6). |
1426 | 768 |
j := 'hello world ' indexOfSeparatorStartingAt:4. |
1447 | 769 |
self assert:(j == 6). |
1426 | 770 |
j := 'hello world ' indexOfSeparatorStartingAt:5. |
771 |
self assert:(j == 6). |
|
772 |
j := 'hello world ' indexOfSeparatorStartingAt:6. |
|
773 |
self assert:(j == 6). |
|
774 |
j := 'hello world ' indexOfSeparatorStartingAt:7. |
|
775 |
self assert:(j == 12). |
|
776 |
j := 'hello world ' indexOfSeparatorStartingAt:8. |
|
777 |
self assert:(j == 12). |
|
778 |
j := 'hello world ' indexOfSeparatorStartingAt:9. |
|
1447 | 779 |
self assert:(j == 12). |
1426 | 780 |
j := 'hello world ' indexOfSeparatorStartingAt:10. |
1447 | 781 |
self assert:(j == 12). |
1426 | 782 |
j := 'hello world ' indexOfSeparatorStartingAt:11. |
783 |
self assert:(j == 12). |
|
784 |
j := 'hello world ' indexOfSeparatorStartingAt:12. |
|
785 |
self assert:(j == 12). |
|
786 |
j := 'hello world' indexOfSeparatorStartingAt:12. |
|
1447 | 787 |
self assert:(j == 0). |
1426 | 788 |
j := 'hello world ' indexOfSeparatorStartingAt:13. |
789 |
self assert:(j == 0). |
|
790 |
j := 'hello world ' indexOfSeparatorStartingAt:10000. |
|
1447 | 791 |
self assert:(j == 0). |
792 |
||
1420 | 793 |
" |
794 |
self new test52_indexOfSeparator |
|
795 |
" |
|
796 |
! |
|
797 |
||
798 |
test54_occurrencesOf |
|
799 |
|s| |
|
800 |
||
801 |
self assert:('' occurrencesOf:$a) == 0. |
|
802 |
1 to:20 do:[:n | |
|
1447 | 803 |
s := (String new:n withAll:$a). |
804 |
self assert:(s occurrencesOf:$a) == n. |
|
805 |
]. |
|
1420 | 806 |
1 to:20 do:[:na | |
1447 | 807 |
1 to:20 do:[:nb | |
808 |
s := (String new:na withAll:$a),(String new:nb withAll:$b). |
|
809 |
self assert:(s occurrencesOf:$a) == na. |
|
810 |
]. |
|
811 |
]. |
|
1420 | 812 |
1 to:40 do:[:n | |
1447 | 813 |
s := String new:n withAll:$a. |
814 |
1 to:n by:2 do:[:n | |
|
815 |
s at:n put:$b. |
|
816 |
]. |
|
817 |
self assert:(s occurrencesOf:$a) == (n // 2). |
|
818 |
]. |
|
819 |
||
1420 | 820 |
s := String new:1000 withAll:$a. |
821 |
self assert:(s occurrencesOf:$a) == 1000. |
|
822 |
1 to:1000 do:[:i | |
|
1447 | 823 |
s at:i put:$b. |
824 |
self assert:(s occurrencesOf:$a) == (1000-i). |
|
825 |
self assert:(s occurrencesOf:$b) == i. |
|
1420 | 826 |
]. |
1447 | 827 |
|
1420 | 828 |
" |
829 |
self new test54_occurrencesOf |
|
830 |
" |
|
831 |
! |
|
832 |
||
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
833 |
test60_hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
834 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
835 |
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
|
836 |
returned different values. This test checks this |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
837 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
838 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
839 |
| tester | |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
840 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
841 |
tester := [:s| |
1447 | 842 |
|sHash u16Hash u32Hash| |
1385 | 843 |
|
1447 | 844 |
sHash := s hash. |
845 |
u16Hash := s asUnicode16String hash. |
|
846 |
u32Hash := s asUnicode32String hash. |
|
1385 | 847 |
|
1447 | 848 |
self assert: sHash == u16Hash |
849 |
description: ('String and Unicode16String hashes differ on "%1" (%2)' |
|
850 |
bindWith:s with:s class name). |
|
851 |
self assert: sHash == u32Hash |
|
852 |
description: ('String and Unicode32String hashes differ on "%1" (%2)' |
|
853 |
bindWith:s with:s class name) |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
854 |
]. |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
855 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
856 |
tester value:'a'. |
1385 | 857 |
tester value:'12345678901234'. |
858 |
tester value:'1234567890123'. |
|
859 |
tester value:'123456789012'. |
|
860 |
tester value:'12345678901'. |
|
861 |
tester value:'1234567890'. |
|
862 |
tester value:'123456789'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
863 |
tester value:'12345678'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
864 |
tester value:'1234567'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
865 |
tester value:'123456'. |
1385 | 866 |
tester value:'12345'. |
867 |
tester value:'1234'. |
|
868 |
tester value:'123'. |
|
869 |
tester value:'12'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
870 |
tester value:'boolean'. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
871 |
|
1417 | 872 |
"/ strings with 0-elements |
873 |
tester value:('' copyWith:Character null). |
|
874 |
tester value:('1' copyWith:Character null). |
|
875 |
tester value:('12' copyWith:Character null). |
|
876 |
tester value:('123' copyWith:Character null). |
|
877 |
tester value:('1234' copyWith:Character null). |
|
878 |
tester value:('12345' copyWith:Character null). |
|
879 |
tester value:('123456' copyWith:Character null). |
|
880 |
tester value:('1234567' copyWith:Character null). |
|
881 |
tester value:('12345678' copyWith:Character null). |
|
882 |
tester value:('123456789' copyWith:Character null). |
|
1419 | 883 |
|
884 |
tester value:('' copyWith:Character null),'123'. |
|
885 |
tester value:('1' copyWith:Character null),'123'. |
|
886 |
tester value:('12' copyWith:Character null),'123'. |
|
887 |
tester value:('123' copyWith:Character null),'123'. |
|
888 |
tester value:('1234' copyWith:Character null),'123'. |
|
889 |
tester value:('12345' copyWith:Character null),'123'. |
|
890 |
tester value:('123456' copyWith:Character null),'123'. |
|
891 |
tester value:('1234567' copyWith:Character null),'123'. |
|
892 |
tester value:('12345678' copyWith:Character null),'123'. |
|
893 |
tester value:('123456789' copyWith:Character null),'123'. |
|
1447 | 894 |
|
1419 | 895 |
"/ String allInstancesDo:[:each| tester value:each]. |
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
896 |
Symbol allInstancesDo:[:each| tester value:each]. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
897 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
898 |
"Created: / 09-01-2013 / 10:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
962
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
899 |
! |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
900 |
|
1426 | 901 |
test65_concatenation |
902 |
|strA strB| |
|
903 |
||
1447 | 904 |
0 to:32 do:[:szA | |
905 |
0 to:32 do:[:szB | |
|
906 |
|szAB| |
|
1426 | 907 |
|
1447 | 908 |
strA := String new:szA withAll:$a. |
909 |
strB := String new:szB withAll:$b. |
|
910 |
szAB := szA + szB. |
|
911 |
self assert:(szA = strA size). |
|
912 |
self assert:(szB = strB size). |
|
913 |
10000 timesRepeat:[ |
|
914 |
|strAB| |
|
1426 | 915 |
|
1447 | 916 |
strAB := strA , strB. |
1426 | 917 |
|
1447 | 918 |
self assert:(szAB == strAB size). |
919 |
] |
|
920 |
] |
|
1426 | 921 |
]. |
922 |
||
923 |
strA := strB := ''. |
|
924 |
self assert: ((strA , strB) = ''). |
|
925 |
self assert: ((strA , strA) = ''). |
|
926 |
strA := 'a'. |
|
1447 | 927 |
self assert: ((strA , strA) = 'aa'). |
1426 | 928 |
self assert: ((strA , strB) = 'a'). |
929 |
strA := ''. |
|
930 |
strB := 'b'. |
|
1447 | 931 |
self assert: ((strA , strB) = 'b'). |
1426 | 932 |
strA := 'b'. |
933 |
strB := 'a'. |
|
1447 | 934 |
self assert: ((strB , strA) = 'ab'). |
1426 | 935 |
" |
936 |
self new test65_concatenation |
|
937 |
" |
|
938 |
! |
|
939 |
||
940 |
test66_replace |
|
941 |
|strA| |
|
942 |
||
943 |
1 to:64 do:[:szA | |
|
1447 | 944 |
strA := String new:szA withAll:$a. |
945 |
1 to:szA do:[:idx | |
|
946 |
strA at:idx put:$*. |
|
1426 | 947 |
|
1447 | 948 |
strA replaceAll:$* with:$#. |
1426 | 949 |
|
1447 | 950 |
self assert:(strA at:idx) = $#. |
951 |
self assert:(strA occurrencesOf:$#) = idx. |
|
952 |
self assert:(strA count:[:ch | ch = $#]) = idx. |
|
953 |
self assert:(strA occurrencesOf:$*) = 0. |
|
954 |
self assert:(strA count:[:ch | ch = $*]) = 0. |
|
955 |
self assert:(strA includes:$#). |
|
956 |
self assert:(strA includes:$*) not. |
|
957 |
] |
|
1426 | 958 |
] |
959 |
||
960 |
" |
|
961 |
self new test66_replace |
|
962 |
" |
|
963 |
! |
|
964 |
||
965 |
test67_concatenationAnd |
|
966 |
|strA strB strC| |
|
967 |
||
1447 | 968 |
0 to:32 do:[:szA | |
969 |
0 to:32 do:[:szB | |
|
970 |
0 to:32 do:[:szC | |
|
971 |
|szABC| |
|
972 |
strA := String new:szA withAll:$a. |
|
973 |
strB := String new:szB withAll:$b. |
|
974 |
strC := String new:szC withAll:$c. |
|
1426 | 975 |
|
1447 | 976 |
szABC := szA + szB + szC. |
977 |
self assert:(szA = strA size). |
|
978 |
self assert:(szB = strB size). |
|
979 |
self assert:(szC = strC size). |
|
1426 | 980 |
|
1447 | 981 |
300 timesRepeat:[ |
982 |
|strABC| |
|
1426 | 983 |
|
1447 | 984 |
strABC := strA concatenate:strB and:strC. |
1426 | 985 |
|
1447 | 986 |
self assert:(szABC == strABC size). |
987 |
] |
|
988 |
] |
|
989 |
] |
|
1426 | 990 |
]. |
991 |
strA := strB := strC := ''. |
|
992 |
self assert: ((strA concatenate:strB and:strC) = ''). |
|
993 |
strA := 'a'. |
|
994 |
self assert: ((strA concatenate:strB and:strC) = 'a'). |
|
995 |
strA := ''. |
|
996 |
strB := 'b'. |
|
1447 | 997 |
self assert: ((strA concatenate:strB and:strC) = 'b'). |
1426 | 998 |
strB := ''. |
999 |
strC := 'c'. |
|
1447 | 1000 |
self assert: ((strA concatenate:strB and:strC) = 'c'). |
1426 | 1001 |
strA := 'c'. |
1002 |
strB := 'b'. |
|
1003 |
strC := 'a'. |
|
1447 | 1004 |
self assert: ((strC concatenate:strB and:strA) = 'abc'). |
1426 | 1005 |
" |
1006 |
self new test67_concatenationAnd |
|
1007 |
" |
|
1008 |
! |
|
1009 |
||
1010 |
test68_concatenationAndAnd |
|
1011 |
|strA strB strC strD| |
|
1012 |
||
1447 | 1013 |
0 to:32 do:[:szA | |
1014 |
strA := String new:szA withAll:$a. |
|
1015 |
self assert:(szA = strA size). |
|
1016 |
0 to:32 do:[:szB | |
|
1017 |
strB := String new:szB withAll:$b. |
|
1018 |
self assert:(szB = strB size). |
|
1019 |
0 to:32 do:[:szC | |
|
1020 |
strC := String new:szC withAll:$c. |
|
1021 |
self assert:(szC = strC size). |
|
1022 |
0 to:32 do:[:szD | |
|
1023 |
|szABCD| |
|
1024 |
strD := String new:szD withAll:$d. |
|
1426 | 1025 |
|
1447 | 1026 |
szABCD := szA + szB + szC + szD. |
1426 | 1027 |
|
1447 | 1028 |
self assert:(szD = strD size). |
1426 | 1029 |
|
1447 | 1030 |
5 timesRepeat:[ |
1031 |
|strABCD| |
|
1426 | 1032 |
|
1447 | 1033 |
strABCD := strA concatenate:strB and:strC and:strD. |
1426 | 1034 |
|
1447 | 1035 |
self assert:(szABCD == strABCD size). |
1036 |
] |
|
1037 |
] |
|
1038 |
] |
|
1039 |
] |
|
1426 | 1040 |
]. |
1041 |
||
1042 |
strA := strB := strC := strD := ''. |
|
1043 |
self assert: ((strA concatenate:strB and:strC and:strD) = ''). |
|
1044 |
strA := 'a'. |
|
1045 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'a'). |
|
1046 |
strA := ''. |
|
1047 |
strB := 'b'. |
|
1447 | 1048 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'b'). |
1426 | 1049 |
strB := ''. |
1050 |
strC := 'c'. |
|
1447 | 1051 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'c'). |
1426 | 1052 |
strC := ''. |
1053 |
strD := 'd'. |
|
1447 | 1054 |
self assert: ((strA concatenate:strB and:strC and:strD) = 'd'). |
1426 | 1055 |
strA := 'd'. |
1056 |
strB := 'c'. |
|
1057 |
strC := 'b'. |
|
1447 | 1058 |
strD := 'a'. |
1059 |
self assert: ((strD concatenate:strC and:strB and:strA) = 'abcd'). |
|
1426 | 1060 |
" |
1061 |
self new test68_concatenationAndAnd |
|
1062 |
" |
|
1063 |
! |
|
1064 |
||
962
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1065 |
test70_storeString |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1066 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1067 |
self assert: 'AAA' storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1068 |
self assert: 'A''A''A' storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1069 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1070 |
self assert: 'AAA' asImmutableString storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1071 |
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
|
1072 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
1073 |
"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
|
1074 |
! |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1075 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1076 |
test80_copyReplaceAll |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1077 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1078 |
| orig copy | |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1079 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1080 |
orig := 'AAA' copy. "/ In case literals are immutable... |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1081 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1082 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1083 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1084 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1085 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1086 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1087 |
orig := 'AAA' asImmutableString. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1088 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1089 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1090 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1091 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1092 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1093 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
1094 |
"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
|
1095 |
! |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1096 |
|
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1097 |
test81_filling |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1098 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1099 |
| str | |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1100 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1101 |
str := 'AAA' copy. "/ In case literals are immutable... |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1102 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1103 |
str atAllPut:$B. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1104 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1105 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1106 |
str from:1 to:0 put:$C. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1107 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1108 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1109 |
str from:1 to:1 put:$D. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1110 |
self assert: str = 'DBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1111 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1112 |
str from:1 to:2 put:$E. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1113 |
self assert: str = 'EEB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1114 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1115 |
str from:1 to:3 put:$F. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1116 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1117 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1118 |
str from:1 to:0 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1119 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1120 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1121 |
str from:-1 to:-2 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1122 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1123 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1124 |
self should:[ |
1421 | 1125 |
str from:-1 to:-1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1126 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1127 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1128 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1129 |
self should:[ |
1421 | 1130 |
str from:-1 to:1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1131 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1132 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1133 |
! |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
1134 |
|
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1135 |
test90_hash |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1136 |
| string8 string16 string32 | |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1137 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1138 |
string8 := 'sun/nio/cs/UTF_8.class'. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1139 |
string16 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1140 |
string32 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1141 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1142 |
self assert: string8 hash == string16 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1143 |
self assert: string8 hash == string32 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1144 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
1145 |
"Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
283 | 1146 |
! ! |
1147 |
||
1148 |
!StringTests class methodsFor:'documentation'! |
|
1149 |
||
1150 |
version |
|
1151 |
^ '$Header$' |
|
570 | 1152 |
! |
1153 |
||
1154 |
version_CVS |
|
1155 |
^ '$Header$' |
|
283 | 1156 |
! ! |
752
ef9236c7271c
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
751
diff
changeset
|
1157 |