author | Claus Gittinger <cg@exept.de> |
Sat, 07 May 2016 13:34:06 +0200 | |
changeset 1418 | 17555e11c398 |
parent 1417 | d624843fda05 |
child 1419 | cfc3eb59fbcf |
permissions | -rw-r--r-- |
283 | 1 |
"{ Package: 'exept:regression' }" |
2 |
||
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#StringTests |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
1060 | 9 |
category:'tests-Regression-Collections' |
283 | 10 |
! |
11 |
||
12 |
||
288 | 13 |
!StringTests methodsFor:'helpers'! |
284 | 14 |
|
288 | 15 |
runAccessTestsOnInstancesOf:aStringClass |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
16 |
|str s0 s1 s2 s3 s4 t| |
284 | 17 |
|
18 |
0 to:33 do:[:l | |
|
1294
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
19 |
str := aStringClass new:l. |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
20 |
str atAllPut:(Character space). |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
21 |
self assert:( str isBlank ). |
284 | 22 |
|
1294
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
23 |
1 to:l do:[:pos | |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
24 |
str at:pos put:$a. |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
25 |
self assert:( str isBlank not ). |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
26 |
str at:pos put:(Character space). |
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
27 |
]. |
284 | 28 |
]. |
29 |
||
288 | 30 |
s0 := aStringClass new:0. |
287 | 31 |
self assert:s0 isEmpty. |
32 |
self assert:s0 isEmptyOrNil. |
|
33 |
self assert:s0 size == 0. |
|
34 |
||
288 | 35 |
s1 := (aStringClass new:5) replaceFrom:1 with:'hello'. |
36 |
s2 := (aStringClass new:6) replaceFrom:1 with:' world'. |
|
285 | 37 |
self assert:(s1 , s2) size == 11. |
288 | 38 |
self assert:(s1 , s2) class == aStringClass. |
285 | 39 |
self assert:(s1 = 'hello'). |
40 |
self assert:(s2 = ' world'). |
|
41 |
self assert:(s1 size == 5). |
|
42 |
self assert:(s2 size == 6). |
|
288 | 43 |
|
285 | 44 |
self assert:(s1 = 'hello'). |
45 |
self assert:(s1 asSymbol == #'hello'). |
|
46 |
self assert:(s1 copyFrom:1) = 'hello'. |
|
288 | 47 |
self assert:(s1 copyFrom:1) class == aStringClass. |
285 | 48 |
self assert:(s1 copyFrom:1 to:3) = 'hel'. |
288 | 49 |
self assert:(s1 copyFrom:1 to:3) class == aStringClass. |
285 | 50 |
self assert:(s1 copyWith:$X) = 'helloX'. |
288 | 51 |
self assert:(s1 copyWith:$X) class == aStringClass. |
285 | 52 |
self assert:(s1 endsWith:'llo'). |
53 |
self assert:(s1 startsWith:'hel'). |
|
286 | 54 |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
55 |
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
|
56 |
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
|
57 |
self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t). |
288 | 58 |
|
59 |
self assert:(s1 identityIndexOf:$h startingAt:1) == 1. |
|
60 |
self assert:(s1 identityIndexOf:$h startingAt:2) == 0. |
|
61 |
self assert:(s1 identityIndexOf:$e startingAt:1) == 2. |
|
62 |
self assert:(s1 identityIndexOf:$e startingAt:2) == 2. |
|
63 |
self assert:(s1 identityIndexOf:$l startingAt:1) == 3. |
|
64 |
self assert:(s1 identityIndexOf:$l startingAt:2) == 3. |
|
65 |
self assert:(s1 identityIndexOf:$l startingAt:3) == 3. |
|
66 |
self assert:(s1 identityIndexOf:$l startingAt:4) == 4. |
|
67 |
self assert:(s1 identityIndexOf:$l startingAt:5) == 0. |
|
68 |
self assert:(s1 identityIndexOf:$l startingAt:6) == 0. |
|
69 |
||
286 | 70 |
self assert:(s1 indexOf:$h) == 1. |
71 |
self assert:(s1 indexOf:$l) == 3. |
|
287 | 72 |
self assert:(s1 indexOf:$L) == 0. |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
73 |
self assert:(s1 indexOf:$A) == 0. |
288 | 74 |
|
286 | 75 |
self assert:(s1 indexOf:$h startingAt:1) == 1. |
76 |
self assert:(s1 indexOf:$h startingAt:2) == 0. |
|
77 |
self assert:(s1 indexOf:$e startingAt:1) == 2. |
|
78 |
self assert:(s1 indexOf:$e startingAt:2) == 2. |
|
79 |
self assert:(s1 indexOf:$l startingAt:1) == 3. |
|
80 |
self assert:(s1 indexOf:$l startingAt:2) == 3. |
|
81 |
self assert:(s1 indexOf:$l startingAt:3) == 3. |
|
82 |
self assert:(s1 indexOf:$l startingAt:4) == 4. |
|
83 |
self assert:(s1 indexOf:$l startingAt:5) == 0. |
|
84 |
self assert:(s1 indexOf:$l startingAt:6) == 0. |
|
288 | 85 |
|
286 | 86 |
self assert:(s1 includes:$l). |
87 |
self assert:(s1 includes:$L) not. |
|
288 | 88 |
|
287 | 89 |
self assert:(s1 includesAny:'a') not. |
90 |
self assert:(s1 includesAny:'ab') not. |
|
91 |
self assert:(s1 includesAny:'abc') not. |
|
92 |
self assert:(s1 includesAny:'abcd') not. |
|
93 |
self assert:(s1 includesAny:'abcde'). |
|
94 |
self assert:(s1 includesAny:'e'). |
|
95 |
self assert:(s1 includesAny:'ae'). |
|
96 |
self assert:(s1 includesAny:'ea'). |
|
97 |
self assert:(s1 includesAny:'abe'). |
|
98 |
self assert:(s1 includesAny:'eab'). |
|
99 |
self assert:(s1 includesAny:'aeb'). |
|
100 |
self assert:(s1 includesAny:'abce'). |
|
101 |
self assert:(s1 includesAny:'eabc'). |
|
102 |
self assert:(s1 includesAny:'aebc'). |
|
103 |
self assert:(s1 includesAny:'abec'). |
|
104 |
self assert:(s1 includesAny:'abcde'). |
|
1294
e4ea07f9fa65
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
1293
diff
changeset
|
105 |
" 12345678901234567890 " |
288 | 106 |
s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'. |
107 |
t := s3 asCollectionOfSubstringsSeparatedBy:$,. |
|
108 |
self assert:(t size = 2). |
|
109 |
self assert:(t first = '12 45'). |
|
110 |
self assert:(t second = '78;01.34-67+90'). |
|
111 |
||
112 |
t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '. |
|
113 |
self assert:(t size = 5). |
|
114 |
self assert:(t first = '12'). |
|
115 |
self assert:(t second = '45'). |
|
116 |
self assert:(t third = '78'). |
|
117 |
self assert:(t fourth = '01'). |
|
118 |
self assert:(t fifth = '34-67+90'). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
119 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
120 |
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
|
121 |
self assert:(s4 size = 10). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
122 |
self assert:(s4 indexOfSeparatorStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
123 |
self assert:(s4 indexOfSeparatorStartingAt:3) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
124 |
self assert:(s4 indexOfSeparatorStartingAt:4) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
125 |
self assert:(s4 indexOfSeparatorStartingAt:5) = 8. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
126 |
self assert:(s4 indexOfControlCharacterStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
127 |
self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
128 |
self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
129 |
self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
130 |
self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5. |
352 | 131 |
! ! |
132 |
||
133 |
!StringTests methodsFor:'tests'! |
|
288 | 134 |
|
135 |
test01_access |
|
136 |
0 to:33 do:[:l | |
|
352 | 137 |
|str| |
288 | 138 |
|
352 | 139 |
str := String new:l. |
140 |
str atAllPut:(Character space). |
|
141 |
self assert:( str isBlank ). |
|
288 | 142 |
|
352 | 143 |
1 to:l do:[:pos | |
144 |
str at:pos put:$a. |
|
145 |
self assert:( str isBlank not ). |
|
146 |
str at:pos put:(Character space). |
|
147 |
]. |
|
288 | 148 |
]. |
149 |
self runAccessTestsOnInstancesOf:String |
|
150 |
||
151 |
" |
|
152 |
self new test01_access |
|
153 |
" |
|
154 |
! |
|
155 |
||
156 |
test02_subclassAccess |
|
157 |
|myStringClass s1| |
|
158 |
||
159 |
Class withoutUpdatingChangesDo:[ |
|
1293 | 160 |
myStringClass := String |
161 |
subclass:#'MyString' |
|
162 |
instanceVariableNames:'foo' |
|
163 |
classVariableNames:'' |
|
164 |
poolDictionaries:nil. |
|
165 |
myStringClass compile:'foo ^foo'. |
|
166 |
myStringClass compile:'foo:arg foo := arg'. |
|
288 | 167 |
]. |
168 |
||
169 |
s1 := (myStringClass new:5) replaceFrom:1 with:'hello'. |
|
170 |
self assert:(s1 foo isNil). |
|
171 |
self assert:(s1 size == 5). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
172 |
s1 foo:16r11413344. "/ ensure there is a $A inside (hex 41) |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
173 |
self assert:(s1 foo == 16r11413344). |
288 | 174 |
self assert:(s1 = 'hello'). |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
175 |
self assert:(s1 deepCopy foo == 16r11413344). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
176 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
177 |
self assert:((s1 indexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
178 |
self assert:((s1 identityIndexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
179 |
self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A |
288 | 180 |
|
181 |
self runAccessTestsOnInstancesOf:myStringClass. |
|
285 | 182 |
|
284 | 183 |
" |
184 |
self new test02_subclassAccess |
|
185 |
" |
|
186 |
! |
|
187 |
||
188 |
test10_Contains8BitCharacters |
|
288 | 189 |
0 to:65 do:[:l | |
352 | 190 |
|str| |
283 | 191 |
|
352 | 192 |
str := String new:l. |
193 |
str atAllPut:(Character value:16r7F). |
|
194 |
self assert:( str contains8BitCharacters not ). |
|
283 | 195 |
|
352 | 196 |
1 to:l do:[:pos | |
197 |
str at:pos put:(Character value:16r80). |
|
198 |
self assert:( str contains8BitCharacters ). |
|
199 |
str at:pos put:(Character value:16r7F). |
|
200 |
]. |
|
283 | 201 |
]. |
202 |
||
203 |
" |
|
284 | 204 |
self new test10_Contains8BitCharacters |
283 | 205 |
" |
288 | 206 |
! |
207 |
||
208 |
test20_literalsAreReadonly |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
209 |
|myClass s1 l2 s2 parserFlags compiler| |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
210 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
211 |
parserFlags := Compiler new parserFlags copy. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
212 |
parserFlags stringsAreImmutable:true. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
213 |
parserFlags arraysAreImmutable:true. |
288 | 214 |
|
215 |
Class withoutUpdatingChangesDo:[ |
|
1293 | 216 |
myClass := Object |
217 |
subclass:#'MyClass' |
|
218 |
instanceVariableNames:'' |
|
219 |
classVariableNames:'' |
|
220 |
poolDictionaries:nil. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
221 |
|
1293 | 222 |
compiler := myClass compilerClass new. |
223 |
compiler parserFlags:parserFlags. |
|
224 |
compiler compile:'lit1 ^''hello''' forClass:myClass install:true. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
225 |
|
1293 | 226 |
compiler := myClass compilerClass new. |
227 |
compiler parserFlags:parserFlags. |
|
228 |
compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true. |
|
288 | 229 |
]. |
230 |
||
231 |
s1 := myClass new perform:#lit1. |
|
232 |
self assert:(s1 isString). |
|
233 |
self assert:(s1 class == ImmutableString). |
|
234 |
self should:[ s1 at:1 put:$H ] raise:Error. |
|
235 |
||
236 |
l2 := myClass new perform:#lit2. |
|
237 |
self assert:(l2 isArray). |
|
238 |
self assert:(l2 class == ImmutableArray). |
|
239 |
self should:[ l2 at:1 put:$H ] raise:Error. |
|
240 |
s2 := l2 at:1. |
|
241 |
self assert:(s2 isString). |
|
242 |
self assert:(s2 class == ImmutableString). |
|
243 |
self should:[ s2 at:1 put:$H ] raise:Error. |
|
244 |
||
245 |
" |
|
246 |
self new test20_literalsAreReadonly |
|
247 |
" |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
248 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
249 |
"Modified: / 02-08-2011 / 19:30:53 / cg" |
352 | 250 |
! |
251 |
||
1418 | 252 |
test30_indexOfSubCollection |
352 | 253 |
|i| |
254 |
"/ 12345678901 |
|
255 |
i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
256 |
self assert:(i == 7). |
|
257 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
258 |
self assert:(i == 0). |
|
259 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
260 |
self assert:(i == 7). |
|
261 |
i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
262 |
self assert:(i == 3). |
|
263 |
||
264 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
265 |
self assert:(i == 3). |
|
266 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false. |
|
267 |
self assert:(i == 3). |
|
268 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false. |
|
269 |
self assert:(i == 15). |
|
270 |
||
353 | 271 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false. |
272 |
self assert:(i == 16). |
|
273 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false. |
|
274 |
self assert:(i == 0). |
|
275 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false. |
|
276 |
self assert:(i == 0). |
|
277 |
||
352 | 278 |
" |
1418 | 279 |
self new test30_indexOfSubCollection |
352 | 280 |
" |
570 | 281 |
! |
282 |
||
283 |
test40_indexOfAny |
|
284 |
|s i| |
|
285 |
||
286 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
287 |
1 to:s size do:[:start | |
|
1308 | 288 |
i := s indexOfAny:'-' startingAt:start. |
289 |
self assert:(i == 0 or:[ i >= start]). |
|
290 |
(i ~~ 0) ifTrue:[ |
|
291 |
self assert:(s at:i) == $- |
|
292 |
]. |
|
293 |
]. |
|
294 |
"/ 123456789012 |
|
295 |
s := 'bla bla 1234'. |
|
296 |
1 to:s size do:[:start | |
|
297 |
i := s indexOfAny:'1234' startingAt:start. |
|
298 |
self assert:(i == 0 or:[ i >= start]). |
|
299 |
(i == 9) ifTrue:[ self assert:((s at:i) == $1) ]. |
|
300 |
(i == 10) ifTrue:[ self assert:((s at:i) == $2) ]. |
|
301 |
(i == 11) ifTrue:[ self assert:((s at:i) == $3) ]. |
|
302 |
(i == 12) ifTrue:[ self assert:((s at:i) == $4) ]. |
|
570 | 303 |
]. |
304 |
||
305 |
" |
|
306 |
self new test40_indexOfAny |
|
307 |
" |
|
308 |
||
309 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
571 | 310 |
! |
311 |
||
1308 | 312 |
test41_contains |
313 |
|s| |
|
314 |
||
315 |
s := 'abcdefg'. |
|
316 |
self assert:(s contains:[:ch | ch == $a]). |
|
317 |
self assert:(s contains:[:ch | ch == $A]) not. |
|
318 |
self assert:(s contains:[:ch | ch == $1]) not. |
|
319 |
||
320 |
" |
|
321 |
self new test41_contains |
|
322 |
" |
|
323 |
! |
|
324 |
||
1418 | 325 |
test42_occurrencesOf |
326 |
|s| |
|
327 |
||
328 |
"/ 12345678901 |
|
329 |
self assert:( 'hello world' occurrencesOf:$0 ) == 0. |
|
330 |
self assert:( 'hello world' occurrencesOf:$l ) == 3. |
|
331 |
self assert:( 'hello world' occurrencesOf:$d ) == 1. |
|
332 |
||
333 |
"/ how about 0-bytes in between |
|
334 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1. |
|
335 |
self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4. |
|
336 |
||
337 |
1 to:10 do:[:nA | |
|
338 |
1 to:10 do:[:nB | |
|
339 |
s := (String new:nA withAll:$a),(String new:nB withAll:$b). |
|
340 |
self assert:(s occurrencesOf:$a) == nA. |
|
341 |
self assert:(s occurrencesOf:$b) == nB. |
|
342 |
] |
|
343 |
]. |
|
344 |
||
345 |
s := String new:1024. |
|
346 |
s atAllPut:$a. |
|
347 |
s at:512 put:(Character space). |
|
348 |
self assert:(s occurrencesOf:(Character space)) == 1. |
|
349 |
self assert:(s occurrencesOf:$a) == 1023. |
|
350 |
||
351 |
s := String new:1024. |
|
352 |
s atAllPut:$a. |
|
353 |
1 to:1024 by:2 do:[:i | s at:i put:$b]. |
|
354 |
self assert:(s occurrencesOf:$a) == 512. |
|
355 |
self assert:(s occurrencesOf:$b) == 512. |
|
356 |
||
357 |
" |
|
358 |
self new test42_occurrencesOf |
|
359 |
" |
|
360 |
||
361 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
362 |
! |
|
363 |
||
571 | 364 |
test50_indexOf |
365 |
|s i| |
|
366 |
||
367 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
368 |
1 to:s size do:[:start | |
|
1418 | 369 |
i := s indexOf:$- startingAt:start. |
370 |
self assert:(i == 0 or:[ i >= start]). |
|
571 | 371 |
]. |
1418 | 372 |
"/ 12345678901 |
373 |
self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0. |
|
374 |
self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3. |
|
375 |
self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10. |
|
376 |
self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11. |
|
377 |
||
378 |
"/ how about 0-bytes in between |
|
379 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3. |
|
380 |
self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4. |
|
381 |
self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5. |
|
382 |
self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4. |
|
383 |
||
384 |
s := '12345678901234b'. |
|
385 |
self assert:(s indexOf:$x) == 0. |
|
386 |
self assert:(s indexOf:$1) == 1. |
|
387 |
self assert:(s indexOf:$2) == 2. |
|
388 |
self assert:(s indexOf:$3) == 3. |
|
389 |
self assert:(s indexOf:$4) == 4. |
|
390 |
self assert:(s indexOf:$5) == 5. |
|
391 |
self assert:(s indexOf:$0) == 10. |
|
392 |
self assert:(s indexOf:$b) == 15. |
|
393 |
||
394 |
s := ''. |
|
395 |
self assert:(s indexOf:$1) == 0. |
|
396 |
s := '1'. |
|
397 |
self assert:(s indexOf:$1) == 1. |
|
398 |
self assert:(s indexOf:$2) == 0. |
|
399 |
s := '12'. |
|
400 |
self assert:(s indexOf:$1) == 1. |
|
401 |
self assert:(s indexOf:$2) == 2. |
|
402 |
self assert:(s indexOf:$3) == 0. |
|
403 |
s := '123'. |
|
404 |
self assert:(s indexOf:$1) == 1. |
|
405 |
self assert:(s indexOf:$2) == 2. |
|
406 |
self assert:(s indexOf:$3) == 3. |
|
407 |
self assert:(s indexOf:$4) == 0. |
|
408 |
s := '1234'. |
|
409 |
self assert:(s indexOf:$1) == 1. |
|
410 |
self assert:(s indexOf:$2) == 2. |
|
411 |
self assert:(s indexOf:$3) == 3. |
|
412 |
self assert:(s indexOf:$4) == 4. |
|
413 |
self assert:(s indexOf:$5) == 0. |
|
414 |
s := '12345'. |
|
415 |
self assert:(s indexOf:$1) == 1. |
|
416 |
self assert:(s indexOf:$2) == 2. |
|
417 |
self assert:(s indexOf:$3) == 3. |
|
418 |
self assert:(s indexOf:$4) == 4. |
|
419 |
self assert:(s indexOf:$5) == 5. |
|
420 |
self assert:(s indexOf:$6) == 0. |
|
421 |
s := '123456'. |
|
422 |
self assert:(s indexOf:$1) == 1. |
|
423 |
self assert:(s indexOf:$2) == 2. |
|
424 |
self assert:(s indexOf:$3) == 3. |
|
425 |
self assert:(s indexOf:$4) == 4. |
|
426 |
self assert:(s indexOf:$5) == 5. |
|
427 |
self assert:(s indexOf:$6) == 6. |
|
428 |
self assert:(s indexOf:$7) == 0. |
|
429 |
s := '1234567'. |
|
430 |
self assert:(s indexOf:$1) == 1. |
|
431 |
self assert:(s indexOf:$2) == 2. |
|
432 |
self assert:(s indexOf:$3) == 3. |
|
433 |
self assert:(s indexOf:$4) == 4. |
|
434 |
self assert:(s indexOf:$5) == 5. |
|
435 |
self assert:(s indexOf:$6) == 6. |
|
436 |
self assert:(s indexOf:$7) == 7. |
|
437 |
self assert:(s indexOf:$8) == 0. |
|
438 |
s := '12345678'. |
|
439 |
self assert:(s indexOf:$1) == 1. |
|
440 |
self assert:(s indexOf:$2) == 2. |
|
441 |
self assert:(s indexOf:$3) == 3. |
|
442 |
self assert:(s indexOf:$4) == 4. |
|
443 |
self assert:(s indexOf:$5) == 5. |
|
444 |
self assert:(s indexOf:$6) == 6. |
|
445 |
self assert:(s indexOf:$7) == 7. |
|
446 |
self assert:(s indexOf:$8) == 8. |
|
447 |
self assert:(s indexOf:$9) == 0. |
|
448 |
s := '123456789'. |
|
449 |
self assert:(s indexOf:$1) == 1. |
|
450 |
self assert:(s indexOf:$2) == 2. |
|
451 |
self assert:(s indexOf:$3) == 3. |
|
452 |
self assert:(s indexOf:$4) == 4. |
|
453 |
self assert:(s indexOf:$5) == 5. |
|
454 |
self assert:(s indexOf:$6) == 6. |
|
455 |
self assert:(s indexOf:$7) == 7. |
|
456 |
self assert:(s indexOf:$8) == 8. |
|
457 |
self assert:(s indexOf:$9) == 9. |
|
458 |
||
459 |
self assert:(s indexOf:$0) == 0. |
|
460 |
self assert:(s indexOf:$b) == 0. |
|
461 |
||
462 |
s := String new:1024. |
|
463 |
s atAllPut:$a. |
|
464 |
s at:512 put:(Character space). |
|
465 |
self assert:(s indexOf:(Character space)) == 512. |
|
466 |
self assert:(s indexOf:(Character space) startingAt:1) == 512. |
|
467 |
self assert:(s indexOf:(Character space) startingAt:2) == 512. |
|
468 |
self assert:(s indexOf:(Character space) startingAt:3) == 512. |
|
469 |
self assert:(s indexOf:(Character space) startingAt:4) == 512. |
|
470 |
self assert:(s indexOf:(Character space) startingAt:5) == 512. |
|
471 |
self assert:(s indexOf:(Character space) startingAt:6) == 512. |
|
472 |
self assert:(s indexOf:(Character space) startingAt:7) == 512. |
|
473 |
self assert:(s indexOf:(Character space) startingAt:8) == 512. |
|
474 |
self assert:(s indexOf:(Character space) startingAt:9) == 512. |
|
475 |
self assert:(s indexOf:(Character space) startingAt:511) == 512. |
|
476 |
self assert:(s indexOf:(Character space) startingAt:512) == 512. |
|
477 |
self assert:(s indexOf:(Character space) startingAt:513) == 0. |
|
571 | 478 |
|
479 |
" |
|
480 |
self new test50_indexOf |
|
481 |
" |
|
482 |
||
483 |
"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
|
484 |
! |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
485 |
|
1373 | 486 |
test51_substrings |
487 |
self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc'). |
|
488 |
self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'. |
|
489 |
||
1385 | 490 |
"/ self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc'). |
491 |
"/ self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'. |
|
492 |
"/ |
|
493 |
"/ self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ). |
|
494 |
"/ self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'. |
|
495 |
"/ |
|
496 |
"/ self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' ''). |
|
497 |
"/ self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '. |
|
498 |
"/ |
|
499 |
"/ self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc'). |
|
500 |
"/ self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'. |
|
1373 | 501 |
|
502 |
" |
|
503 |
self new test51_substrings |
|
504 |
" |
|
505 |
! |
|
506 |
||
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
507 |
test60_hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
508 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
509 |
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
|
510 |
returned different values. This test checks this |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
511 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
512 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
513 |
| tester | |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
514 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
515 |
tester := [:s| |
1385 | 516 |
|sHash u16Hash u32Hash| |
517 |
||
518 |
sHash := s hash. |
|
519 |
u16Hash := s asUnicode16String hash. |
|
520 |
u32Hash := s asUnicode32String hash. |
|
521 |
||
522 |
self assert: sHash == u16Hash |
|
1389 | 523 |
description: ('String and Unicode16String hashes differ on "%1" (%2)' |
524 |
bindWith:s with:s class name). |
|
1385 | 525 |
self assert: sHash == u32Hash |
1389 | 526 |
description: ('String and Unicode32String hashes differ on "%1" (%2)' |
527 |
bindWith:s with:s class name) |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
528 |
]. |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
529 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
530 |
tester value:'a'. |
1385 | 531 |
tester value:'12345678901234'. |
532 |
tester value:'1234567890123'. |
|
533 |
tester value:'123456789012'. |
|
534 |
tester value:'12345678901'. |
|
535 |
tester value:'1234567890'. |
|
536 |
tester value:'123456789'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
537 |
tester value:'12345678'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
538 |
tester value:'1234567'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
539 |
tester value:'123456'. |
1385 | 540 |
tester value:'12345'. |
541 |
tester value:'1234'. |
|
542 |
tester value:'123'. |
|
543 |
tester value:'12'. |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
544 |
tester value:'boolean'. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
545 |
|
1417 | 546 |
"/ strings with 0-elements |
547 |
tester value:('' copyWith:Character null). |
|
548 |
tester value:('1' copyWith:Character null). |
|
549 |
tester value:('12' copyWith:Character null). |
|
550 |
tester value:('123' copyWith:Character null). |
|
551 |
tester value:('1234' copyWith:Character null). |
|
552 |
tester value:('12345' copyWith:Character null). |
|
553 |
tester value:('123456' copyWith:Character null). |
|
554 |
tester value:('1234567' copyWith:Character null). |
|
555 |
tester value:('12345678' copyWith:Character null). |
|
556 |
tester value:('123456789' copyWith:Character null). |
|
557 |
||
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
558 |
String allInstancesDo:[:each| tester value:each]. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
559 |
Symbol allInstancesDo:[:each| tester value:each]. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
560 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
561 |
"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
|
562 |
! |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
563 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
564 |
test70_storeString |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
565 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
566 |
self assert: 'AAA' storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
567 |
self assert: 'A''A''A' storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
568 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
569 |
self assert: 'AAA' asImmutableString storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
570 |
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
|
571 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
572 |
"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
|
573 |
! |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
574 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
575 |
test80_copyReplaceAll |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
576 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
577 |
| orig copy | |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
578 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
579 |
orig := 'AAA' copy. "/ In case literals are immutable... |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
580 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
581 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
582 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
583 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
584 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
585 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
586 |
orig := 'AAA' asImmutableString. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
587 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
588 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
589 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
590 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
591 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
592 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
593 |
"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
|
594 |
! |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
595 |
|
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
596 |
test81_filling |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
597 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
598 |
| str | |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
599 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
600 |
str := 'AAA' copy. "/ In case literals are immutable... |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
601 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
602 |
str atAllPut:$B. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
603 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
604 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
605 |
str from:1 to:0 put:$C. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
606 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
607 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
608 |
str from:1 to:1 put:$D. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
609 |
self assert: str = 'DBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
610 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
611 |
str from:1 to:2 put:$E. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
612 |
self assert: str = 'EEB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
613 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
614 |
str from:1 to:3 put:$F. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
615 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
616 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
617 |
str from:1 to:0 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
618 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
619 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
620 |
str from:-1 to:-2 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
621 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
622 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
623 |
self should:[ |
1293 | 624 |
str from:-1 to:-1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
625 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
626 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
627 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
628 |
self should:[ |
1293 | 629 |
str from:-1 to:1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
630 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
631 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
632 |
! |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
633 |
|
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
634 |
test90_hash |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
635 |
| string8 string16 string32 | |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
636 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
637 |
string8 := 'sun/nio/cs/UTF_8.class'. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
638 |
string16 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
639 |
string32 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
640 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
641 |
self assert: string8 hash == string16 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
642 |
self assert: string8 hash == string32 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
643 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
644 |
"Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
283 | 645 |
! ! |
646 |
||
647 |
!StringTests class methodsFor:'documentation'! |
|
648 |
||
649 |
version |
|
650 |
^ '$Header$' |
|
570 | 651 |
! |
652 |
||
653 |
version_CVS |
|
654 |
^ '$Header$' |
|
283 | 655 |
! ! |
752
ef9236c7271c
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
751
diff
changeset
|
656 |