author | Claus Gittinger <cg@exept.de> |
Sun, 30 Aug 2015 07:39:47 +0200 | |
changeset 1293 | ed6726eb8a4a |
parent 1240 | 4b187f56458b |
child 1294 | e4ea07f9fa65 |
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 |
|
1293 | 15 |
testAsLowercase |
16 |
|s| |
|
17 |
||
18 |
s := ((Character value:0) to:(Character value:16rFFFF)) asString. |
|
19 |
||
288 | 20 |
runAccessTestsOnInstancesOf:aStringClass |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
21 |
|str s0 s1 s2 s3 s4 t| |
284 | 22 |
|
23 |
0 to:33 do:[:l | |
|
1293 | 24 |
str := aStringClass new:l. |
25 |
str atAllPut:(Character space). |
|
26 |
self assert:( str isBlank ). |
|
284 | 27 |
|
1293 | 28 |
1 to:l do:[:pos |. |
29 |
str at:pos put:$a. |
|
30 |
self assert:( str isBlank not ). |
|
31 |
str at:pos put:(Character space). |
|
32 |
]. |
|
284 | 33 |
]. |
34 |
||
288 | 35 |
s0 := aStringClass new:0. |
287 | 36 |
self assert:s0 isEmpty. |
37 |
self assert:s0 isEmptyOrNil. |
|
38 |
self assert:s0 size == 0. |
|
39 |
||
288 | 40 |
s1 := (aStringClass new:5) replaceFrom:1 with:'hello'. |
41 |
s2 := (aStringClass new:6) replaceFrom:1 with:' world'. |
|
285 | 42 |
self assert:(s1 , s2) size == 11. |
288 | 43 |
self assert:(s1 , s2) class == aStringClass. |
285 | 44 |
self assert:(s1 = 'hello'). |
45 |
self assert:(s2 = ' world'). |
|
46 |
self assert:(s1 size == 5). |
|
47 |
self assert:(s2 size == 6). |
|
288 | 48 |
|
285 | 49 |
self assert:(s1 = 'hello'). |
50 |
self assert:(s1 asSymbol == #'hello'). |
|
51 |
self assert:(s1 copyFrom:1) = 'hello'. |
|
288 | 52 |
self assert:(s1 copyFrom:1) class == aStringClass. |
285 | 53 |
self assert:(s1 copyFrom:1 to:3) = 'hel'. |
288 | 54 |
self assert:(s1 copyFrom:1 to:3) class == aStringClass. |
285 | 55 |
self assert:(s1 copyWith:$X) = 'helloX'. |
288 | 56 |
self assert:(s1 copyWith:$X) class == aStringClass. |
285 | 57 |
self assert:(s1 endsWith:'llo'). |
58 |
self assert:(s1 startsWith:'hel'). |
|
286 | 59 |
|
702
4c5fb5598e9e
changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents:
635
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t). |
288 | 63 |
|
64 |
self assert:(s1 identityIndexOf:$h startingAt:1) == 1. |
|
65 |
self assert:(s1 identityIndexOf:$h startingAt:2) == 0. |
|
66 |
self assert:(s1 identityIndexOf:$e startingAt:1) == 2. |
|
67 |
self assert:(s1 identityIndexOf:$e startingAt:2) == 2. |
|
68 |
self assert:(s1 identityIndexOf:$l startingAt:1) == 3. |
|
69 |
self assert:(s1 identityIndexOf:$l startingAt:2) == 3. |
|
70 |
self assert:(s1 identityIndexOf:$l startingAt:3) == 3. |
|
71 |
self assert:(s1 identityIndexOf:$l startingAt:4) == 4. |
|
72 |
self assert:(s1 identityIndexOf:$l startingAt:5) == 0. |
|
73 |
self assert:(s1 identityIndexOf:$l startingAt:6) == 0. |
|
74 |
||
286 | 75 |
self assert:(s1 indexOf:$h) == 1. |
76 |
self assert:(s1 indexOf:$l) == 3. |
|
287 | 77 |
self assert:(s1 indexOf:$L) == 0. |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
78 |
self assert:(s1 indexOf:$A) == 0. |
288 | 79 |
|
286 | 80 |
self assert:(s1 indexOf:$h startingAt:1) == 1. |
81 |
self assert:(s1 indexOf:$h startingAt:2) == 0. |
|
82 |
self assert:(s1 indexOf:$e startingAt:1) == 2. |
|
83 |
self assert:(s1 indexOf:$e startingAt:2) == 2. |
|
84 |
self assert:(s1 indexOf:$l startingAt:1) == 3. |
|
85 |
self assert:(s1 indexOf:$l startingAt:2) == 3. |
|
86 |
self assert:(s1 indexOf:$l startingAt:3) == 3. |
|
87 |
self assert:(s1 indexOf:$l startingAt:4) == 4. |
|
88 |
self assert:(s1 indexOf:$l startingAt:5) == 0. |
|
89 |
self assert:(s1 indexOf:$l startingAt:6) == 0. |
|
288 | 90 |
|
286 | 91 |
self assert:(s1 includes:$l). |
92 |
self assert:(s1 includes:$L) not. |
|
288 | 93 |
|
287 | 94 |
self assert:(s1 includesAny:'a') not. |
95 |
self assert:(s1 includesAny:'ab') not. |
|
96 |
self assert:(s1 includesAny:'abc') not. |
|
97 |
self assert:(s1 includesAny:'abcd') not. |
|
98 |
self assert:(s1 includesAny:'abcde'). |
|
99 |
self assert:(s1 includesAny:'e'). |
|
100 |
self assert:(s1 includesAny:'ae'). |
|
101 |
self assert:(s1 includesAny:'ea'). |
|
102 |
self assert:(s1 includesAny:'abe'). |
|
103 |
self assert:(s1 includesAny:'eab'). |
|
104 |
self assert:(s1 includesAny:'aeb'). |
|
105 |
self assert:(s1 includesAny:'abce'). |
|
106 |
self assert:(s1 includesAny:'eabc'). |
|
107 |
self assert:(s1 includesAny:'aebc'). |
|
108 |
self assert:(s1 includesAny:'abec'). |
|
109 |
self assert:(s1 includesAny:'abcde'). |
|
1293 | 110 |
" 12345678901234567890 " |
288 | 111 |
s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'. |
112 |
t := s3 asCollectionOfSubstringsSeparatedBy:$,. |
|
113 |
self assert:(t size = 2). |
|
114 |
self assert:(t first = '12 45'). |
|
115 |
self assert:(t second = '78;01.34-67+90'). |
|
116 |
||
117 |
t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '. |
|
118 |
self assert:(t size = 5). |
|
119 |
self assert:(t first = '12'). |
|
120 |
self assert:(t second = '45'). |
|
121 |
self assert:(t third = '78'). |
|
122 |
self assert:(t fourth = '01'). |
|
123 |
self assert:(t fifth = '34-67+90'). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
124 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
125 |
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
|
126 |
self assert:(s4 size = 10). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
127 |
self assert:(s4 indexOfSeparatorStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
128 |
self assert:(s4 indexOfSeparatorStartingAt:3) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
129 |
self assert:(s4 indexOfSeparatorStartingAt:4) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
130 |
self assert:(s4 indexOfSeparatorStartingAt:5) = 8. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
131 |
self assert:(s4 indexOfControlCharacterStartingAt:1) = 4. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
132 |
self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
133 |
self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
134 |
self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5. |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
135 |
self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5. |
352 | 136 |
! ! |
137 |
||
138 |
!StringTests methodsFor:'tests'! |
|
288 | 139 |
|
140 |
test01_access |
|
141 |
0 to:33 do:[:l | |
|
352 | 142 |
|str| |
288 | 143 |
|
352 | 144 |
str := String new:l. |
145 |
str atAllPut:(Character space). |
|
146 |
self assert:( str isBlank ). |
|
288 | 147 |
|
352 | 148 |
1 to:l do:[:pos | |
149 |
str at:pos put:$a. |
|
150 |
self assert:( str isBlank not ). |
|
151 |
str at:pos put:(Character space). |
|
152 |
]. |
|
288 | 153 |
]. |
154 |
self runAccessTestsOnInstancesOf:String |
|
155 |
||
156 |
" |
|
157 |
self new test01_access |
|
158 |
" |
|
159 |
! |
|
160 |
||
161 |
test02_subclassAccess |
|
162 |
|myStringClass s1| |
|
163 |
||
164 |
Class withoutUpdatingChangesDo:[ |
|
1293 | 165 |
myStringClass := String |
166 |
subclass:#'MyString' |
|
167 |
instanceVariableNames:'foo' |
|
168 |
classVariableNames:'' |
|
169 |
poolDictionaries:nil. |
|
170 |
myStringClass compile:'foo ^foo'. |
|
171 |
myStringClass compile:'foo:arg foo := arg'. |
|
288 | 172 |
]. |
173 |
||
174 |
s1 := (myStringClass new:5) replaceFrom:1 with:'hello'. |
|
175 |
self assert:(s1 foo isNil). |
|
176 |
self assert:(s1 size == 5). |
|
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
177 |
s1 foo:16r11413344. "/ ensure there is a $A inside (hex 41) |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
178 |
self assert:(s1 foo == 16r11413344). |
288 | 179 |
self assert:(s1 = 'hello'). |
874
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
180 |
self assert:(s1 deepCopy foo == 16r11413344). |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
181 |
|
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
182 |
self assert:((s1 indexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
183 |
self assert:((s1 identityIndexOf:$A) == 0). "/ should not find the A |
7936c9ee23d5
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
873
diff
changeset
|
184 |
self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A |
288 | 185 |
|
186 |
self runAccessTestsOnInstancesOf:myStringClass. |
|
285 | 187 |
|
284 | 188 |
" |
189 |
self new test02_subclassAccess |
|
190 |
" |
|
191 |
! |
|
192 |
||
193 |
test10_Contains8BitCharacters |
|
288 | 194 |
0 to:65 do:[:l | |
352 | 195 |
|str| |
283 | 196 |
|
352 | 197 |
str := String new:l. |
198 |
str atAllPut:(Character value:16r7F). |
|
199 |
self assert:( str contains8BitCharacters not ). |
|
283 | 200 |
|
352 | 201 |
1 to:l do:[:pos | |
202 |
str at:pos put:(Character value:16r80). |
|
203 |
self assert:( str contains8BitCharacters ). |
|
204 |
str at:pos put:(Character value:16r7F). |
|
205 |
]. |
|
283 | 206 |
]. |
207 |
||
208 |
" |
|
284 | 209 |
self new test10_Contains8BitCharacters |
283 | 210 |
" |
288 | 211 |
! |
212 |
||
213 |
test20_literalsAreReadonly |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
214 |
|myClass s1 l2 s2 parserFlags compiler| |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
215 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
216 |
parserFlags := Compiler new parserFlags copy. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
217 |
parserFlags stringsAreImmutable:true. |
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
218 |
parserFlags arraysAreImmutable:true. |
288 | 219 |
|
220 |
Class withoutUpdatingChangesDo:[ |
|
1293 | 221 |
myClass := Object |
222 |
subclass:#'MyClass' |
|
223 |
instanceVariableNames:'' |
|
224 |
classVariableNames:'' |
|
225 |
poolDictionaries:nil. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
226 |
|
1293 | 227 |
compiler := myClass compilerClass new. |
228 |
compiler parserFlags:parserFlags. |
|
229 |
compiler compile:'lit1 ^''hello''' forClass:myClass install:true. |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
230 |
|
1293 | 231 |
compiler := myClass compilerClass new. |
232 |
compiler parserFlags:parserFlags. |
|
233 |
compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true. |
|
288 | 234 |
]. |
235 |
||
236 |
s1 := myClass new perform:#lit1. |
|
237 |
self assert:(s1 isString). |
|
238 |
self assert:(s1 class == ImmutableString). |
|
239 |
self should:[ s1 at:1 put:$H ] raise:Error. |
|
240 |
||
241 |
l2 := myClass new perform:#lit2. |
|
242 |
self assert:(l2 isArray). |
|
243 |
self assert:(l2 class == ImmutableArray). |
|
244 |
self should:[ l2 at:1 put:$H ] raise:Error. |
|
245 |
s2 := l2 at:1. |
|
246 |
self assert:(s2 isString). |
|
247 |
self assert:(s2 class == ImmutableString). |
|
248 |
self should:[ s2 at:1 put:$H ] raise:Error. |
|
249 |
||
250 |
" |
|
251 |
self new test20_literalsAreReadonly |
|
252 |
" |
|
605
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
253 |
|
6f0411c4d46f
changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents:
571
diff
changeset
|
254 |
"Modified: / 02-08-2011 / 19:30:53 / cg" |
352 | 255 |
! |
256 |
||
257 |
test30_indexOf |
|
258 |
|i| |
|
259 |
"/ 12345678901 |
|
260 |
i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
261 |
self assert:(i == 7). |
|
262 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true. |
|
263 |
self assert:(i == 0). |
|
264 |
i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
265 |
self assert:(i == 7). |
|
266 |
i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
267 |
self assert:(i == 3). |
|
268 |
||
269 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false. |
|
270 |
self assert:(i == 3). |
|
271 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false. |
|
272 |
self assert:(i == 3). |
|
273 |
i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false. |
|
274 |
self assert:(i == 15). |
|
275 |
||
353 | 276 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false. |
277 |
self assert:(i == 16). |
|
278 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false. |
|
279 |
self assert:(i == 0). |
|
280 |
i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false. |
|
281 |
self assert:(i == 0). |
|
282 |
||
352 | 283 |
" |
284 |
self new test30_indexOf |
|
285 |
" |
|
570 | 286 |
! |
287 |
||
288 |
test40_indexOfAny |
|
289 |
|s i| |
|
290 |
||
291 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
292 |
1 to:s size do:[:start | |
|
1293 | 293 |
i := s indexOfAny:'-' startingAt:start. |
294 |
self assert:(i == 0 or:[ i >= start]). |
|
570 | 295 |
]. |
296 |
||
297 |
" |
|
298 |
self new test40_indexOfAny |
|
299 |
" |
|
300 |
||
301 |
"Created: / 29-10-2010 / 14:58:21 / cg" |
|
571 | 302 |
! |
303 |
||
304 |
test50_indexOf |
|
305 |
|s i| |
|
306 |
||
307 |
s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'. |
|
308 |
1 to:s size do:[:start | |
|
1293 | 309 |
i := s indexOf:$- startingAt:start. |
310 |
self assert:(i == 0 or:[ i >= start]). |
|
571 | 311 |
]. |
312 |
||
313 |
" |
|
314 |
self new test50_indexOf |
|
315 |
" |
|
316 |
||
317 |
"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
|
318 |
! |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
319 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
320 |
test60_hash |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
321 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
322 |
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
|
323 |
returned different values. This test checks this |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
324 |
" |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
325 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
326 |
| tester | |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
327 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
328 |
tester := [:s| |
1293 | 329 |
self assert: s hash == s asUnicode16String hash |
330 |
description: 'String and Unicode16String hashes differ!!'. |
|
331 |
self assert: s hash == s asUnicode32String hash |
|
332 |
description: 'String and Unicode32String hashes differ!!'. |
|
333 |
self assert: s asUnicode16String hash == s asUnicode32String hash |
|
334 |
description: 'Unicode16String and Unicode32String hashes differ!!'. |
|
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
335 |
]. |
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
336 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
337 |
tester value:'a'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
338 |
tester value:'12345678'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
339 |
tester value:'1234567'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
340 |
tester value:'123456'. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
341 |
tester value:'boolean'. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
342 |
|
753
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
343 |
String allInstancesDo:[:each| tester value:each]. |
81af28f807cf
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
752
diff
changeset
|
344 |
Symbol allInstancesDo:[:each| tester value:each]. |
751
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
345 |
|
8c9ff6c5efe2
Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
702
diff
changeset
|
346 |
"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
|
347 |
! |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
348 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
349 |
test70_storeString |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
350 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
351 |
self assert: 'AAA' storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
352 |
self assert: 'A''A''A' storeString = '''A''''A''''A'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
353 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
354 |
self assert: 'AAA' asImmutableString storeString = '''AAA'''. |
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
355 |
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
|
356 |
|
2fca937dc59b
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
874
diff
changeset
|
357 |
"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
|
358 |
! |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
359 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
360 |
test80_copyReplaceAll |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
361 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
362 |
| orig copy | |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
363 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
364 |
orig := 'AAA' copy. "/ In case literals are immutable... |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
365 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
366 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
367 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
368 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
369 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
370 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
371 |
orig := 'AAA' asImmutableString. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
372 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
373 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
374 |
copy := orig copyReplaceAll: $A with: $X. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
375 |
self assert: copy = 'XXX'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
376 |
self assert: orig = 'AAA'. |
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
377 |
|
373c0f5e539d
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1060
diff
changeset
|
378 |
"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
|
379 |
! |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
380 |
|
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
381 |
test81_filling |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
382 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
383 |
| str | |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
384 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
385 |
str := 'AAA' copy. "/ In case literals are immutable... |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
386 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
387 |
str atAllPut:$B. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
388 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
389 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
390 |
str from:1 to:0 put:$C. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
391 |
self assert: str = 'BBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
392 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
393 |
str from:1 to:1 put:$D. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
394 |
self assert: str = 'DBB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
395 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
396 |
str from:1 to:2 put:$E. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
397 |
self assert: str = 'EEB'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
398 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
399 |
str from:1 to:3 put:$F. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
400 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
401 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
402 |
str from:1 to:0 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
403 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
404 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
405 |
str from:-1 to:-2 put:$G. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
406 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
407 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
408 |
self should:[ |
1293 | 409 |
str from:-1 to:-1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
410 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
411 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
412 |
|
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
413 |
self should:[ |
1293 | 414 |
str from:-1 to:1 put:$x |
1240
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
415 |
] raise:SubscriptOutOfBoundsError. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
416 |
self assert: str = 'FFF'. |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
417 |
! |
4b187f56458b
class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
418 |
|
1214
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
419 |
test90_hash |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
420 |
| string8 string16 string32 | |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
421 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
422 |
string8 := 'sun/nio/cs/UTF_8.class'. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
423 |
string16 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
424 |
string32 := string8 asUnicode16String. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
425 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
426 |
self assert: string8 hash == string16 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
427 |
self assert: string8 hash == string32 hash. |
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
428 |
|
11cb005634cb
class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1103
diff
changeset
|
429 |
"Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
283 | 430 |
! ! |
431 |
||
432 |
!StringTests class methodsFor:'documentation'! |
|
433 |
||
434 |
version |
|
435 |
^ '$Header$' |
|
570 | 436 |
! |
437 |
||
438 |
version_CVS |
|
439 |
^ '$Header$' |
|
283 | 440 |
! ! |
752
ef9236c7271c
class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents:
751
diff
changeset
|
441 |