RegressionTests__StringTests.st
author sr
Thu, 06 Feb 2020 11:20:09 +0100
changeset 2558 a557369b74e2
parent 2465 dafd40caecba
child 2564 4e29ca66fa6b
permissions -rw-r--r--
#BUGFIX by Stefan Reise class: WebSocketTest::DemoWebSocketService class changed: #defaultPort
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1990
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
     1
"{ Encoding: utf8 }"
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#StringTests
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
     8
	instanceVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
     9
	classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
    10
	poolDictionaries:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
    11
	category:'tests-Regression-Collections'
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1425
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    15
!StringTests class methodsFor:'queries'!
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    16
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    17
coveredClassNames
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    18
    "should be redefined to return a collection of classes which are tested by
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    19
     this suite/case.
1425
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    20
     If not redefined, coveredPackageNames should be.
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    21
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    22
     These classes can be instrumented for coverage analysis,
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    23
     before running the suite to provide coverage analysis/report"
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    24
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    25
    ^ #( String CharacterArray )
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    26
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    27
    "Created: / 06-07-2011 / 21:27:03 / cg"
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    28
! !
66a1a63431a0 #QUALITY by mawalch
mawalch
parents: 1421
diff changeset
    29
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    30
!StringTests methodsFor:'helpers'!
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    31
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    32
runAccessTestsOnInstancesOf:aStringClass
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    33
    |str s0 s1 s2 s3 s4 t|
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    34
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    35
    0 to:33 do:[:l |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    36
	str := aStringClass new:l.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    37
	str atAllPut:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    38
	self assert:( str isBlank ).
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    39
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    40
	1 to:l do:[:pos |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    41
	    str at:pos put:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    42
	    self assert:( str isBlank not ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    43
	    str at:pos put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
    44
	].
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    45
    ].
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
    46
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    47
    s0 := aStringClass new:0.
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    48
    self assert:s0 isEmpty.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    49
    self assert:s0 isEmptyOrNil.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    50
    self assert:s0 size == 0.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    51
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    52
    s1 := (aStringClass new:5) replaceFrom:1 with:'hello'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    53
    s2 := (aStringClass new:6) replaceFrom:1 with:' world'.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    54
    self assert:(s1 , s2) size == 11.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    55
    self assert:(s1 , s2) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    56
    self assert:(s1 = 'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    57
    self assert:(s2 = ' world').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    58
    self assert:(s1 size == 5).
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    59
    self assert:(s2 size == 6).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    60
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    61
    self assert:(s1 = 'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    62
    self assert:(s1 asSymbol == #'hello').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    63
    self assert:(s1 copyFrom:1) = 'hello'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    64
    self assert:(s1 copyFrom:1) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    65
    self assert:(s1 copyFrom:1 to:3) = 'hel'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    66
    self assert:(s1 copyFrom:1 to:3) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    67
    self assert:(s1 copyWith:$X) = 'helloX'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    68
    self assert:(s1 copyWith:$X) class == aStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    69
    self assert:(s1 endsWith:'llo').
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
    70
    self assert:(s1 startsWith:'hel').
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    71
702
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    72
    self assert:(t := s1 identityIndexOf:$h) == 1 description:('identityIndex is %1 (should be 1)' bindWith:t).
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    73
    self assert:(t := s1 identityIndexOf:$l) == 3 description:('identityIndex is %1 (should be 3)' bindWith:t).
4c5fb5598e9e changed: #runAccessTestsOnInstancesOf:
Claus Gittinger <cg@exept.de>
parents: 635
diff changeset
    74
    self assert:(t := s1 identityIndexOf:$L) == 0 description:('identityIndex is %1 (should be 0)' bindWith:t).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    75
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    76
    self assert:(s1 identityIndexOf:$h startingAt:1) == 1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    77
    self assert:(s1 identityIndexOf:$h startingAt:2) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    78
    self assert:(s1 identityIndexOf:$e startingAt:1) == 2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    79
    self assert:(s1 identityIndexOf:$e startingAt:2) == 2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    80
    self assert:(s1 identityIndexOf:$l startingAt:1) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    81
    self assert:(s1 identityIndexOf:$l startingAt:2) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    82
    self assert:(s1 identityIndexOf:$l startingAt:3) == 3.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    83
    self assert:(s1 identityIndexOf:$l startingAt:4) == 4.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    84
    self assert:(s1 identityIndexOf:$l startingAt:5) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    85
    self assert:(s1 identityIndexOf:$l startingAt:6) == 0.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    86
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    87
    self assert:(s1 indexOf:$h) == 1.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    88
    self assert:(s1 indexOf:$l) == 3.
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
    89
    self assert:(s1 indexOf:$L) == 0.
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
    90
    self assert:(s1 indexOf:$A) == 0.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
    91
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    92
    self assert:(s1 indexOf:$h startingAt:1) == 1.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    93
    self assert:(s1 indexOf:$h startingAt:2) == 0.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    94
    self assert:(s1 indexOf:$e startingAt:1) == 2.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    95
    self assert:(s1 indexOf:$e startingAt:2) == 2.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    96
    self assert:(s1 indexOf:$l startingAt:1) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    97
    self assert:(s1 indexOf:$l startingAt:2) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    98
    self assert:(s1 indexOf:$l startingAt:3) == 3.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    99
    self assert:(s1 indexOf:$l startingAt:4) == 4.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   100
    self assert:(s1 indexOf:$l startingAt:5) == 0.
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   101
    self assert:(s1 indexOf:$l startingAt:6) == 0.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   102
286
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   103
    self assert:(s1 includes:$l).
bf494c929515 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
   104
    self assert:(s1 includes:$L) not.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   105
287
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   106
    self assert:(s1 includesAny:'a') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   107
    self assert:(s1 includesAny:'ab') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   108
    self assert:(s1 includesAny:'abc') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   109
    self assert:(s1 includesAny:'abcd') not.
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   110
    self assert:(s1 includesAny:'abcde').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   111
    self assert:(s1 includesAny:'e').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   112
    self assert:(s1 includesAny:'ae').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   113
    self assert:(s1 includesAny:'ea').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   114
    self assert:(s1 includesAny:'abe').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   115
    self assert:(s1 includesAny:'eab').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   116
    self assert:(s1 includesAny:'aeb').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   117
    self assert:(s1 includesAny:'abce').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   118
    self assert:(s1 includesAny:'eabc').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   119
    self assert:(s1 includesAny:'aebc').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   120
    self assert:(s1 includesAny:'abec').
e19c028a4dc5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 286
diff changeset
   121
    self assert:(s1 includesAny:'abcde').
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   122
						  " 12345678901234567890 "
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   123
    s3 := (aStringClass new:20) replaceFrom:1 with:'12 45,78;01.34-67+90'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   124
    t := s3 asCollectionOfSubstringsSeparatedBy:$,.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   125
    self assert:(t size = 2).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   126
    self assert:(t first = '12 45').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   127
    self assert:(t second = '78;01.34-67+90').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   128
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   129
    t := s3 asCollectionOfSubstringsSeparatedByAny:',;. '.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   130
    self assert:(t size = 5).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   131
    self assert:(t first = '12').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   132
    self assert:(t second = '45').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   133
    self assert:(t third = '78').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   134
    self assert:(t fourth = '01').
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   135
    self assert:(t fifth = '34-67+90').
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   136
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   137
    s4 := (aStringClass new:10) replaceFrom:1 with:'123',Character tab,'567',Character cr,'90'.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   138
    self assert:(s4 size = 10).
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   139
    self assert:(s4 indexOfSeparatorStartingAt:1) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   140
    self assert:(s4 indexOfSeparatorStartingAt:3) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   141
    self assert:(s4 indexOfSeparatorStartingAt:4) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   142
    self assert:(s4 indexOfSeparatorStartingAt:5) = 8.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   143
    self assert:(s4 indexOfControlCharacterStartingAt:1) = 4.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   144
    self assert:(s4 indexOfNonSeparatorStartingAt:1) = 1.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   145
    self assert:(s4 indexOfNonSeparatorStartingAt:3) = 3.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   146
    self assert:(s4 indexOfNonSeparatorStartingAt:4) = 5.
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   147
    self assert:(s4 indexOfNonSeparatorStartingAt:5) = 5.
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   148
! !
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   149
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   150
!StringTests methodsFor:'tests'!
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   151
2365
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   152
bench_stringSearch
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   153
    "
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   154
     self new bench_stringSearch
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   155
    "
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   156
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   157
    |haystack toBeFoundAtEnd|
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   158
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   159
    toBeFoundAtEnd := '0123456789012345678901234567890123456789'.
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   160
    haystack := String new:50000.
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   161
    haystack := String new:1000.
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   162
    haystack replaceFrom:(haystack size-toBeFoundAtEnd size) with:toBeFoundAtEnd.
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   163
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   164
    #(
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   165
        $0
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   166
        '0'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   167
        '01'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   168
        '012'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   169
        '0123'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   170
        '01234'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   171
        '012345'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   172
        '0123456'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   173
        '01234567'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   174
        '012345678'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   175
        '0123456789'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   176
        '01234567890123456789'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   177
        '0123456789012345678901234567890123456789'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   178
        '01234567890123456789012345678901234567890123456789'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   179
        '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   180
    ) do:[:needle |
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   181
        |micros i|
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   182
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   183
        needle isCharacter ifTrue:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   184
            micros := Time microsecondsToRun:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   185
                    1000 timesRepeat:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   186
                        haystack indexOf:needle startingAt:1
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   187
                    ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   188
                 ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   189
            i := haystack indexOf:needle startingAt:1
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   190
        ] ifFalse:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   191
            micros := Time microsecondsToRun:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   192
                    1000 timesRepeat:[
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   193
                        haystack indexOfSubCollection:needle startingAt:1 ifAbsent:0 caseSensitive:true
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   194
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   195
                    ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   196
                 ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   197
            i := haystack indexOfSubCollection:needle startingAt:1 ifAbsent:(haystack size) caseSensitive:true.
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   198
        ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   199
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   200
        Transcript showCR:'size %1: t=%2 (%3 chars/second)' 
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   201
                     with:(needle isCharacter ifTrue:[1] ifFalse:[needle size])
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   202
                     with:(TimeDuration microseconds:micros)
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   203
                     with:(UnitConverter 
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   204
                            unitStringFor:((i*1000000.0) / micros )
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   205
                            scale:1000 rounded:true
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   206
                            unitStrings:#('' 'k' 'M' 'G' 'T' 'P' 'E' )).
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   207
    ].
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   208
!
c49d92aa47aa #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2364
diff changeset
   209
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   210
test01_access
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   211
    0 to:33 do:[:l |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   212
	|str|
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   213
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   214
	str := String new:l.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   215
	str atAllPut:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   216
	self assert:( str isBlank ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   217
	self assert:((str size == 0) or: [(str first) == Character space.]).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   218
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   219
	1 to:l do:[:pos |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   220
	    str at:pos put:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   221
	    self assert:( str isBlank not ).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   222
	    self assert:((str at:pos) == $a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   223
	    str at:pos put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   224
	].
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   225
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   226
    self runAccessTestsOnInstancesOf:String
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   227
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   228
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   229
     self new test01_access
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   230
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   231
!
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   232
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   233
test02_subclassAccess
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   234
    |myStringClass s1|
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   235
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   236
    Class withoutUpdatingChangesDo:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   237
	myStringClass := String
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   238
			subclass:#'MyString'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   239
			instanceVariableNames:'foo'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   240
			classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   241
			poolDictionaries:nil.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   242
	myStringClass compile:'foo ^foo'.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   243
	myStringClass compile:'foo:arg foo := arg'.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   244
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   245
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   246
    s1 := (myStringClass new:5) replaceFrom:1 with:'hello'.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   247
    self assert:(s1 foo isNil).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   248
    self assert:(s1 size == 5).
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   249
    s1 foo:16r11413344.         "/ ensure there is a $A inside (hex 41)
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   250
    self assert:(s1 foo == 16r11413344).
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   251
    self assert:(s1 = 'hello').
874
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   252
    self assert:(s1 deepCopy foo == 16r11413344).
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   253
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   254
    self assert:((s1 indexOf:$A) == 0).                 "/ should not find the A
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   255
    self assert:((s1 identityIndexOf:$A) == 0).         "/ should not find the A
7936c9ee23d5 class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 873
diff changeset
   256
    self assert:((s1 findFirst:[:ch | ch == $A]) == 0). "/ should not find the A
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   257
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   258
    self runAccessTestsOnInstancesOf:myStringClass.
285
11e1200a3625 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   259
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   260
    "
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   261
     self new test02_subclassAccess
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   262
    "
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   263
!
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   264
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   265
test03a_unicode16
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   266
    |u s u2|
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   267
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   268
    u := 'hello' asUnicode16String.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   269
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   270
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   271
    self assert:((u at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   272
    self assert:((u at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   273
    self assert:((u at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   274
    self assert:((u at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   275
    self assert:((u at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   276
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   277
    s := u asSingleByteString.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   278
    self assert:(s class == String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   279
    self assert:(s size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   280
    self assert:((s at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   281
    self assert:((s at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   282
    self assert:((s at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   283
    self assert:((s at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   284
    self assert:((s at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   285
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   286
    s := u asSingleByteStringIfPossible.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   287
    self assert:(s class == String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   288
    self assert:(s size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   289
    self assert:((s at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   290
    self assert:((s at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   291
    self assert:((s at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   292
    self assert:((s at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   293
    self assert:((s at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   294
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   295
    u2 := 'hello' asUnicode16String.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   296
    u2 at:1 put:(Character codePoint:16r20AC).   "/ euro character
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   297
    self assert:(u2 size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   298
    self assert:((u2 at:1) = (Character codePoint:16r20AC)).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   299
    self assert:((u2 at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   300
    self assert:((u2 at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   301
    self assert:((u2 at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   302
    self assert:((u2 at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   303
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   304
    s := u2 asSingleByteStringIfPossible.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   305
    self assert:(s class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   306
    self assert:(u2 == s).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   307
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   308
    u := Unicode16String fromString:'hello'.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   309
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   310
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   311
    self assert:((u at:1) == $h).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   312
    self assert:((u at:2) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   313
    self assert:((u at:3) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   314
    self assert:((u at:4) == $l).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   315
    self assert:((u at:5) == $o).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   316
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   317
    u replaceFrom:1 to:5 with:'abcde' startingAt:1.
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   318
    self assert:(u class == Unicode16String).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   319
    self assert:(u size == 5).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   320
    self assert:((u at:1) == $a).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   321
    self assert:((u at:2) == $b).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   322
    self assert:((u at:3) == $c).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   323
    self assert:((u at:4) == $d).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   324
    self assert:((u at:5) == $e).
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   325
    
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   326
    "
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   327
     self new test03a_unicode16
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   328
    "
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   329
2209
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   330
    "Created: / 02-04-2019 / 10:43:49 / Claus Gittinger"
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   331
!
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   332
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   333
test03b_unicode32
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   334
    |u s u2|
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   335
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   336
    u := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   337
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   338
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   339
    self assert:((u at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   340
    self assert:((u at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   341
    self assert:((u at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   342
    self assert:((u at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   343
    self assert:((u at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   344
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   345
    s := u asSingleByteString.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   346
    self assert:(s class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   347
    self assert:(s size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   348
    self assert:((s at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   349
    self assert:((s at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   350
    self assert:((s at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   351
    self assert:((s at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   352
    self assert:((s at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   353
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   354
    s := u asSingleByteStringIfPossible.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   355
    self assert:(s class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   356
    self assert:(s size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   357
    self assert:((s at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   358
    self assert:((s at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   359
    self assert:((s at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   360
    self assert:((s at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   361
    self assert:((s at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   362
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   363
    u2 := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   364
    u2 at:1 put:(Character codePoint:16r20AC).   "/ euro character
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   365
    self assert:(u2 size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   366
    self assert:((u2 at:1) = (Character codePoint:16r20AC)).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   367
    self assert:((u2 at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   368
    self assert:((u2 at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   369
    self assert:((u2 at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   370
    self assert:((u2 at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   371
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   372
    s := u2 asSingleByteStringIfPossible.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   373
    self assert:(s class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   374
    self assert:(u2 == s).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   375
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   376
    u := Unicode32String fromString:'hello'.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   377
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   378
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   379
    self assert:((u at:1) == $h).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   380
    self assert:((u at:2) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   381
    self assert:((u at:3) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   382
    self assert:((u at:4) == $l).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   383
    self assert:((u at:5) == $o).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   384
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   385
    u replaceFrom:1 to:5 with:'abcde' startingAt:1.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   386
    self assert:(u class == Unicode32String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   387
    self assert:(u size == 5).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   388
    self assert:((u at:1) == $a).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   389
    self assert:((u at:2) == $b).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   390
    self assert:((u at:3) == $c).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   391
    self assert:((u at:4) == $d).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   392
    self assert:((u at:5) == $e).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   393
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   394
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   395
     self new test03b_unicode32
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   396
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   397
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   398
    "Created: / 02-04-2019 / 10:44:34 / Claus Gittinger"
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   399
!
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   400
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   401
test03c_unicodeStrings
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   402
    |u32 u16 u8|
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   403
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   404
    u32 := 'hello' asUnicode32String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   405
    u16 := 'hello' asUnicode16String.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   406
    u8 := 'hello' asString.
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   407
    self assert:(u32 = u16).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   408
    self assert:(u16 = u32).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   409
    self assert:(u32 = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   410
    self assert:(u8 = u32).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   411
    self assert:(u16 = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   412
    self assert:(u8 = u16).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   413
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   414
    self assert:(u32 asDenseUnicodeString = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   415
    self assert:(u32 asDenseUnicodeString class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   416
    self assert:(u16 asDenseUnicodeString = u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   417
    self assert:(u16 asDenseUnicodeString class == String).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   418
    self assert:(u8 asDenseUnicodeString == u8).
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   419
    
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   420
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   421
     self new test03c_unicodeStrings
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   422
    "
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   423
dd72456e8de4 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
   424
    "Created: / 02-04-2019 / 10:46:10 / Claus Gittinger"
1693
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   425
!
04a3687c829e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   426
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   427
test10_Contains8BitCharacters
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   428
    0 to:65 do:[:l |
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   429
	|str|
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   431
	str := String new:l.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   432
	str atAllPut:(Character value:16r7F).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   433
	self assert:( str contains8BitCharacters not ).
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   435
	1 to:l do:[:pos |
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   436
	    str at:pos put:(Character value:16r80).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   437
	    self assert:( str contains8BitCharacters ).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   438
	    str at:pos put:(Character value:16r7F).
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   439
	].
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
    ].
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    "
284
5a049629081c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 283
diff changeset
   443
     self new test10_Contains8BitCharacters
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
    "
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   445
!
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   446
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   447
test11_IsEmpty
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   448
    |nul n|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   449
    nul := 0 asCharacter.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   450
    n := 1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   451
    self assert:('' isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   452
    self assert:(' ' isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   453
    self assert:(nul asCharacter asString isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   454
    self assert:(('' , nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   455
    self assert:((String new:0) isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   456
    self assert:((String new:17 withAll:nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   457
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   458
    29 timesRepeat:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   459
	|s|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   460
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   461
	s := String new:(n + 17).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   462
	self assert:(s isEmpty not).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   463
	n := n * 2.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   464
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   465
    self assert:((String new:17 withAll:nul) isEmpty not).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   466
    self assert:((String new:0 withAll:nul) isEmpty).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   467
    "
1429
0201c6bd39a4 #DOCUMENTATION by mawalch
mawalch
parents: 1428
diff changeset
   468
     self new test11_IsEmpty
0201c6bd39a4 #DOCUMENTATION by mawalch
mawalch
parents: 1428
diff changeset
   469
    "
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   470
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   471
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   472
test12_Comparison
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   473
    0 to: 255 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   474
	|s t|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   475
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   476
	1 to: 9 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   477
	    s := String new:j withAll:(i asCharacter).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   478
	    t := s copy.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   479
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   480
	    self assert:(s notNil).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   481
	    self assert:(s = s).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   482
	    self assert:(s ~= s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   483
	    self assert:(s < s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   484
	    self assert:(s > s) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   485
	    self assert:(s = (s,s)) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   486
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   487
	    self assert:(t notNil).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   488
	    self assert:(s = t).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   489
	    self assert:(s ~= t) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   490
	    self assert:(s < t) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   491
	    self assert:(s > t) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   492
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   493
	    self assert:((s = nil) == ((s ~= nil) not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   494
	    self assert:((s = '') == ((s ~= '') not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   495
	].
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   496
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   497
	s := i asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   498
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   499
	    t := j asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   500
	    self assert:(t notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   501
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   502
	    self assert:((s = t) == ((s ~= t) not)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   503
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   504
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   505
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   506
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   507
     self new test12_Comparison
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   508
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   509
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   510
1990
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   511
test13_startsWithEndsWithSameAs
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   512
    self assert:('hello' startsWith:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   513
    self assert:('hello' startsWith:'h').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   514
    self assert:('hello' startsWith:'he').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   515
    self assert:('hello' startsWith:'hel').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   516
    self assert:('hello' startsWith:'hell').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   517
    self assert:('hello' startsWith:'hello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   518
    self assert:('hello' startsWith:'hello world') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   519
    "/ int size
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   520
    self assert:('1234' startsWith:'123').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   521
    self assert:('1234' startsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   522
    self assert:('1234' startsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   523
    self assert:('12345678' startsWith:'123').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   524
    self assert:('12345678' startsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   525
    self assert:('12345678' startsWith:'12345').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   526
    self assert:('12345678' startsWith:'123456').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   527
    self assert:('12345678' startsWith:'1234567').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   528
    self assert:('12345678' startsWith:'12345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   529
    self assert:('12345678' startsWith:'123456789') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   530
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   531
    self assert:('1234' startsWith:'x23') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   532
    self assert:('1234' startsWith:'x234') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   533
    self assert:('1234' startsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   534
    self assert:('1234' startsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   535
    self assert:('1234' startsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   536
    self assert:('1234' startsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   537
    self assert:('12345678' startsWith:'x234') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   538
    self assert:('12345678' startsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   539
    self assert:('12345678' startsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   540
    self assert:('12345678' startsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   541
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   542
    self assert:('hello' endsWith:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   543
    self assert:('hello' endsWith:'o').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   544
    self assert:('hello' endsWith:'lo').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   545
    self assert:('hello' endsWith:'llo').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   546
    self assert:('hello' endsWith:'ello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   547
    self assert:('hello' endsWith:'hello').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   548
    self assert:('hello' endsWith:'hello world') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   549
    "/ int size
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   550
    self assert:('1234' endsWith:'234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   551
    self assert:('1234' endsWith:'1234').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   552
    self assert:('1234' endsWith:'1235') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   553
    self assert:('1234' endsWith:'12345') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   554
    self assert:('12345678' endsWith:'678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   555
    self assert:('12345678' endsWith:'5678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   556
    self assert:('12345678' endsWith:'45678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   557
    self assert:('12345678' endsWith:'345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   558
    self assert:('12345678' endsWith:'2345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   559
    self assert:('12345678' endsWith:'12345678').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   560
    self assert:('12345678' endsWith:'123456789') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   561
    self assert:('12345678' endsWith:'012345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   562
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   563
    self assert:('1234' endsWith:'x233') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   564
    self assert:('1234' endsWith:'1x34') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   565
    self assert:('1234' endsWith:'12x4') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   566
    self assert:('1234' endsWith:'123x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   567
    self assert:('12345678' endsWith:'x2345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   568
    self assert:('12345678' endsWith:'1x345678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   569
    self assert:('12345678' endsWith:'12x45678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   570
    self assert:('12345678' endsWith:'123x5678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   571
    self assert:('12345678' endsWith:'1234x678') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   572
    self assert:('12345678' endsWith:'12345x78') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   573
    self assert:('12345678' endsWith:'123456x8') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   574
    self assert:('12345678' endsWith:'1234567x') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   575
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   576
    self assert:('' sameAs:'').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   577
    self assert:('' sameAs:'a') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   578
    self assert:('a' sameAs:'') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   579
    self assert:('a' sameAs:'a').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   580
    self assert:('a' sameAs:'A').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   581
    self assert:('A' sameAs:'A').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   582
    self assert:('A' sameAs:'a').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   583
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   584
    self assert:('a' sameAs:'1') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   585
    self assert:('A' sameAs:'1') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   586
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   587
    1 to:20 do:[:len |
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   588
        |s1 s2|
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   589
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   590
        s1 := ($a to:($a + len - 1)) asString.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   591
        s2 := s1 copy.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   592
        1 to:len do:[:idx |
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   593
            s2 at:idx put:(s2 at:idx) asUppercase.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   594
            self assert:(s1 sameAs:s2).
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   595
        ].
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   596
    ].
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   597
    
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   598
    self assert:('Ä' sameAs:'ä').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   599
    self assert:('Ä' sameAs:'ä').
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   600
    self assert:('ß' sameAs:'ÿ') not.
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   601
    self assert:('Ÿ' sameAs:'ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   602
    self assert:('Ÿ' sameAs:'Ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   603
    self assert:('ÿ' sameAs:'ÿ'). "/ single byte char ws. wide char
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   604
    
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   605
    "
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   606
     self new test13_startsWithEndsWithSameAs
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   607
    "
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   608
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   609
    "Created: / 19-07-2018 / 11:05:32 / Claus Gittinger"
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   610
!
add7e46a1fac #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1693
diff changeset
   611
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   612
test15_CompareWithCollating
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   613
    | nul |
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   614
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   615
    nul := 0 asCharacter asString.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   616
    self assert:('' compareWith:'' collating:true) == 0.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   617
    self assert:('' compareWith:'' collating:false) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   618
    self assert:(nul compareWith:(255 asCharacter asString) collating:false) == -1.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   619
    self assert:((255 asCharacter asString) compareWith:nul collating:false) == 1.
1433
6291f067c336 #REFACTORING by mawalch
mawalch
parents: 1430
diff changeset
   620
    "/ This will fail and is a WONTFIX
6291f067c336 #REFACTORING by mawalch
mawalch
parents: 1430
diff changeset
   621
    "/ self assert:((('' compareWith:nul collating:false) == 0) == ('' = nul)).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   622
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   623
    0 to: 255 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   624
	|s|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   625
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   626
	s := i asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   627
	self assert:(s notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   628
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   629
	"/ This will fail and is a WONTFIX
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   630
	"/ self assert:('' compareWith:s collating:false) ~= 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   631
	self assert:('' compareWith:s collating:false) == ((s compareWith:'' collating:false) negated).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   632
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   633
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   634
	    | t |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   635
	    t := j asCharacter asString.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   636
	    self assert:(t notNil).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   637
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   638
	    self assert:(((s compareWith:t collating:false) == -1) == (s < t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   639
	    self assert:(((s compareWith:t collating:false) == 0) == (s = t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   640
	    self assert:(((s compareWith:t collating:false) == 1) == (s > t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   641
	    self assert:(((s compareWith:t collating:true) == -1) == (s < t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   642
	    self assert:(((s compareWith:t collating:true) == 0) == (s = t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   643
	    self assert:(((s compareWith:t collating:true) == 1) == (s > t)).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   644
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   645
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   646
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   647
    0 to: 9 do: [ :i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   648
	0 to: 255 do: [ :j |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   649
	    |s t|
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   650
	    s := String new:i withAll:(j asCharacter).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   651
	    t := s copy.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   652
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   653
	    self assert: (s compareWith:s collating:false) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   654
	    self assert: (s compareWith:s collating:true) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   655
	    self assert: (s compareWith:t collating:false) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   656
	    self assert: (s compareWith:t collating:true) == 0
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   657
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   658
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   659
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   660
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   661
     self new test15_CompareWithCollating
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   662
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   663
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   664
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   665
test20_literalsAreReadonly
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   666
    |myClass s1 l2 s2 parserFlags compiler|
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   667
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   668
    parserFlags := Compiler new parserFlags copy.
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   669
    parserFlags stringsAreImmutable:true.
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   670
    parserFlags arraysAreImmutable:true.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   671
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   672
    Class withoutUpdatingChangesDo:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   673
	myClass := Object
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   674
			subclass:#'MyClass'
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   675
			instanceVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   676
			classVariableNames:''
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   677
			poolDictionaries:nil.
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   678
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   679
	compiler := myClass compilerClass new.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   680
	compiler parserFlags:parserFlags.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   681
	compiler compile:'lit1 ^''hello''' forClass:myClass install:true.
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   682
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   683
	compiler := myClass compilerClass new.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   684
	compiler parserFlags:parserFlags.
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   685
	compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true.
288
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   686
    ].
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   687
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   688
    s1 := myClass new perform:#lit1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   689
    self assert:(s1 isString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   690
    self assert:(s1 class == ImmutableString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   691
    self should:[ s1 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   692
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   693
    l2 := myClass new perform:#lit2.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   694
    self assert:(l2 isArray).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   695
    self assert:(l2 class == ImmutableArray).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   696
    self should:[ l2 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   697
    s2 := l2 at:1.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   698
    self assert:(s2 isString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   699
    self assert:(s2 class == ImmutableString).
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   700
    self should:[ s2 at:1 put:$H ] raise:Error.
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   701
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   702
    "
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   703
     self new test20_literalsAreReadonly
453fbe5663a8 immutable strings
Claus Gittinger <cg@exept.de>
parents: 287
diff changeset
   704
    "
605
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   705
6f0411c4d46f changed: #test20_literalsAreReadonly
Claus Gittinger <cg@exept.de>
parents: 571
diff changeset
   706
    "Modified: / 02-08-2011 / 19:30:53 / cg"
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   707
!
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   708
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   709
test30_indexOfSubCollection
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   710
    |i|
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   711
      "/  12345678901
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   712
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   713
    self assert:(i == 7).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   714
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   715
    self assert:(i == 0).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   716
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   717
    self assert:(i == 7).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   718
    i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   719
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   720
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   721
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   722
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   723
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   724
    self assert:(i == 3).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   725
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false.
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   726
    self assert:(i == 15).
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   727
353
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   728
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   729
    self assert:(i == 16).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   730
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   731
    self assert:(i == 0).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   732
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false.
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   733
    self assert:(i == 0).
70a6187c1f2b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   734
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   735
    i := 'world' indexOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   736
    self assert:(i == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   737
    i := 'world' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   738
    self assert:(i == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   739
    i := 'world' indexOfString:'world' startingAt:6.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   740
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   741
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   742
    i := 'hello world' indexOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   743
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   744
    i := 'hello world' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   745
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   746
    i := 'hello world' indexOfString:'world' startingAt:4.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   747
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   748
    i := 'hello world' indexOfString:'world' startingAt:7.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   749
    self assert:(i == 7).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   750
    i := 'hello world' indexOfString:'world' startingAt:8.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   751
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   752
    
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   753
    i := 'hello wOrLd' indexOfString:'world' startingAt:1.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   754
    self assert:(i == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   755
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   756
    "
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
   757
     self new test30_indexOfSubCollection
352
7196bdd29f7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   758
    "
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   759
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   760
    "Modified: / 25-05-2019 / 09:01:43 / Claus Gittinger"
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   761
!
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   762
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   763
test30b_indexOfSubCollection
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   764
    |i|
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   765
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   766
      "/  12345678901
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   767
    i := 'hello world' indexOfSubCollection:'w' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   768
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   769
    i := 'hello world' indexOfSubCollection:'w' startingAt:6 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   770
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   771
    i := 'hello world' indexOfSubCollection:'w' startingAt:7 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   772
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   773
    i := 'hello world' indexOfSubCollection:'w' startingAt:8 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   774
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   775
    i := 'hello world' indexOfSubCollection:'x' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   776
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   777
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   778
      "/  12345678901
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   779
    i := 'hello world' indexOfSubCollection:'wo' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   780
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   781
    i := 'hello world' indexOfSubCollection:'wo' startingAt:6 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   782
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   783
    i := 'hello world' indexOfSubCollection:'wo' startingAt:7 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   784
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   785
    i := 'hello world' indexOfSubCollection:'wo' startingAt:8 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   786
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   787
    i := 'hello world' indexOfSubCollection:'xx' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   788
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   789
    i := 'hello world' indexOfSubCollection:'wO' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   790
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   791
    i := 'hello world' indexOfSubCollection:'wO' startingAt:6 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   792
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   793
    i := 'hello world' indexOfSubCollection:'wO' startingAt:7 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   794
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   795
    i := 'hello world' indexOfSubCollection:'wO' startingAt:8 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   796
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   797
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   798
      "/  12345678901
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   799
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   800
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   801
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   802
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   803
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   804
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   805
    i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   806
    self assert:(i == 3).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   807
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   808
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   809
    self assert:(i == 3).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   810
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   811
    self assert:(i == 3).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   812
    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   813
    self assert:(i == 15).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   814
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   815
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   816
    self assert:(i == 16).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   817
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   818
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   819
    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   820
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   821
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   822
    i := 'world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   823
    self assert:(i == 1).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   824
    i := 'world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   825
    self assert:(i == 1).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   826
    i := 'world' indexOfSubCollection:'world' startingAt:2 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   827
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   828
    i := 'world' indexOfSubCollection:'world' startingAt:2 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   829
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   830
    i := 'world' indexOfSubCollection:'world' startingAt:6 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   831
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   832
    i := 'world' indexOfSubCollection:'world' startingAt:6 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   833
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   834
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   835
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   836
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   837
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   838
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   839
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   840
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   841
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   842
    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   843
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   844
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   845
    i := 'hello world' indexOfSubCollection:'world' startingAt:4 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   846
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   847
    i := 'hello world' indexOfSubCollection:'world' startingAt:4 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   848
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   849
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   850
    i := 'hello world' indexOfSubCollection:'world' startingAt:7 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   851
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   852
    i := 'hello world' indexOfSubCollection:'world' startingAt:7 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   853
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   854
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   855
    i := 'hello world' indexOfSubCollection:'world' startingAt:8 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   856
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   857
    i := 'hello world' indexOfSubCollection:'world' startingAt:8 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   858
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   859
    
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   860
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   861
    self assert:(i == 0).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   862
    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   863
    self assert:(i == 7).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   864
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   865
    "
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   866
     self new test30b_indexOfSubCollection
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   867
    "
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   868
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   869
    "Modified: / 25-05-2019 / 09:01:43 / Claus Gittinger"
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   870
!
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
   871
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   872
test31_occurrencesOfString
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   873
    |n|
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   874
      "/  12345678901
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   875
    n := 'hello world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   876
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   877
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   878
    n := 'hello wOrLd world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   879
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   880
2242
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   881
    n := 'hello wOrLd world' occurrencesOfString:'world' caseSensitive:false.
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   882
    self assert:(n == 2).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   883
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   884
    n := 'hello world hello world' occurrencesOfString:'world'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   885
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   886
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   887
    n := '' occurrencesOfString:'aa'.
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   888
    self assert:(n == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   889
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   890
    n := 'a' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   891
    self assert:(n == 0).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   892
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   893
    n := 'aa' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   894
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   895
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   896
    n := ' aa ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   897
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   898
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   899
    n := ' aa a' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   900
    self assert:(n == 1).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   901
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   902
    n := ' aaaa' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   903
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   904
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   905
    n := ' aa aa ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   906
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   907
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   908
    n := ' aa bb ab ba aa ab' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   909
    self assert:(n == 2).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   910
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   911
    n := ' aa bb cc aa bb cc aa bb ' occurrencesOfString:'aa'.  
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   912
    self assert:(n == 3).
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   913
2242
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   914
    n := ' aa bb cc aA bb cc Aa bb ' occurrencesOfString:'aa'.  
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   915
    self assert:(n == 1).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   916
    n := ' aa bb cc aA bb cc Aa bb ' occurrencesOfString:'aa' caseSensitive:false.  
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   917
    self assert:(n == 3).
6ed9be004635 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2241
diff changeset
   918
2241
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   919
    "
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   920
     self new test31_occurrencesOfString
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   921
    "
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   922
748bb1185b08 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   923
    "Created: / 25-05-2019 / 09:03:11 / Claus Gittinger"
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   924
!
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   925
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   926
test40_indexOfAny
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   927
    |s i collection|
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   928
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   929
    s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'.
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   930
    1 to:s size do:[:start |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   931
	i := s indexOfAny:'-' startingAt:start.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   932
	self assert:(i == 0 or:[ i >= start]).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   933
	(i ~~ 0) ifTrue:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   934
	    self assert:(s at:i) == $-
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   935
	].
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   936
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   937
    "/    123456789012
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   938
    s := 'bla bla 1234'.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   939
    1 to:s size do:[:start |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   940
	i := s indexOfAny:'1234' startingAt:start.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   941
	self assert:(i == 0 or:[ i >= start]).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   942
	(i == 9) ifTrue:[ self assert:((s at:i) == $1) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   943
	(i == 10) ifTrue:[ self assert:((s at:i) == $2) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   944
	(i == 11) ifTrue:[ self assert:((s at:i) == $3) ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   945
	(i == 12) ifTrue:[ self assert:((s at:i) == $4) ].
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   946
    ].
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   947
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   948
    collection := #($o, $l, $o).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   949
      "/  12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   950
    i := 'hello world' indexOfAny:collection startingAt:1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   951
    self assert:(i == 3).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   952
    i := 'hello world' indexOfAny:collection startingAt:2.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   953
    self assert:(i == 3).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   954
    i := 'hello world' indexOfAny:collection startingAt:3.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   955
    self assert:(i == 3).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   956
    i := 'hello world' indexOfAny:collection startingAt:4.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   957
    self assert:(i == 4).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   958
    i := 'hello world' indexOfAny:collection startingAt:5.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   959
    self assert:(i == 5).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   960
    i := 'hello world' indexOfAny:collection startingAt:6.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   961
    self assert:(i == 8).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   962
    i := 'hello world' indexOfAny:collection startingAt:7.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   963
    self assert:(i == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   964
    i := 'hello world' indexOfAny:collection startingAt:8.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   965
    self assert:(i == 8).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   966
    i := 'hello world' indexOfAny:collection startingAt:9.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   967
    self assert:(i == 10).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   968
    i := 'hello world' indexOfAny:collection startingAt:10.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
   969
    self assert:(i == 10).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   970
    i := 'hello world' indexOfAny:collection startingAt:11.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   971
    self assert:(i == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   972
    i := 'hello world' indexOfAny:collection startingAt:12.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   973
    self assert:(i == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   974
    i := 'hello world' indexOfAny:collection startingAt:10000.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   975
    self assert:(i == 0).
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   976
    "
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   977
     self new test40_indexOfAny
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   978
    "
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   979
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   980
    "Created: / 29-10-2010 / 14:58:21 / cg"
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   981
!
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
   982
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   983
test41_contains
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   984
    |s|
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   985
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   986
    s := 'abcdefg'.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   987
    self assert:(s contains:[:ch | ch == $a]).
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   988
    self assert:(s contains:[:ch | ch == $A]) not.
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   989
    self assert:(s contains:[:ch | ch == $1]) not.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
   990
    self assert:(s contains:[:ch | ch == (0 asCharacter)]) not.
1308
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   991
    "
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   992
     self new test41_contains
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   993
    "
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   994
!
0514727b0371 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   995
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   996
test42a_includesAny
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   997
    |s|
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   998
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   999
    1 to:20 do:[:na |
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1000
        s := (String new:na withAll:$a),'bla bla 1234'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1001
        self assert:( s includesAny:'12').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1002
        self assert:( s includesAny:'21').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1003
        self assert:( s includesAny:'15').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1004
        self assert:( s includesAny:'51').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1005
        self assert:( s includesAny:'45').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1006
        self assert:( s includesAny:'54').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1007
        self assert:( s includesAny:'56') not.
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1008
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1009
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1010
    "
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1011
     self new test42a_includesAny
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1012
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1013
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1014
    "Created: / 02-04-2019 / 11:03:13 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1015
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1016
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1017
test42b_includesMatchCharacters
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1018
    self assert:('hello' includesMatchCharacters not).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1019
    self assert:('he*llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1020
    self assert:('h[eE]llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1021
    self assert:('h#llo' includesMatchCharacters).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1022
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1023
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1024
     self new test42b_includesMatchCharacters
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1025
    "
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1026
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1027
    "Created: / 02-04-2019 / 11:03:46 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1028
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1029
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1030
test42c_includesSeparator
2388
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1031
    self assert:('' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1032
    self assert:('a' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1033
    self assert:('ab' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1034
    self assert:('abc' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1035
    self assert:('abcd' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1036
    self assert:('abcde' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1037
    self assert:('abcdef' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1038
    self assert:('abcdefg' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1039
    self assert:('abcdefgh' includesSeparator not).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1040
    self assert:('a ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1041
    self assert:('ab ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1042
    self assert:('abc ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1043
    self assert:('abcd ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1044
    self assert:('abcde ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1045
    self assert:('abcdef ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1046
    self assert:('abcdefg ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1047
    self assert:('abcdefgh ' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1048
    self assert:(' a' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1049
    self assert:(' ab' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1050
    self assert:(' abc' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1051
    self assert:(' abcd' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1052
    self assert:(' abcde' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1053
    self assert:(' abcdef' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1054
    self assert:(' abcdefg' includesSeparator).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  1055
    self assert:(' abcdefgh' includesSeparator).
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1056
    self assert:('hello' includesSeparator not).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1057
    self assert:('he llo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1058
    self assert:(' hello' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1059
    self assert:('hello ' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1060
    self assert:(' he llo ' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1061
    self assert:(c'h\nllo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1062
    self assert:(c'h\tllo' includesSeparator).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1063
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1064
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1065
     self new test42c_includesSeparator
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1066
    "
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1067
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1068
    "Created: / 02-04-2019 / 11:05:39 / Claus Gittinger"
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1069
!
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1070
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1071
test43_occurrencesOf
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1072
    |s|
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1073
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1074
    "/             12345678901
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1075
    self assert:( 'hello world' occurrencesOf:$0 ) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1076
    self assert:( 'hello world' occurrencesOf:$l ) == 3.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1077
    self assert:( 'hello world' occurrencesOf:$d ) == 1.
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1078
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1079
    "/ how about 0-bytes in between
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1080
    self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:1) ) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1081
    self assert:( #[0 0 1 0 0] asString occurrencesOf:(Character value:0) ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1082
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1083
    1 to:10 do:[:nA |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1084
	1 to:10 do:[:nB |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1085
	    s := (String new:nA withAll:$a),(String new:nB withAll:$b).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1086
	    self assert:(s occurrencesOf:$a) == nA.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1087
	    self assert:(s occurrencesOf:$b) == nB.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1088
	]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1089
    ].
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1090
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1091
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1092
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1093
    s at:512 put:(Character space).
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1094
    self assert:(s occurrencesOf:(Character space)) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1095
    self assert:(s occurrencesOf:$a) == 1023.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1096
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1097
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1098
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1099
    1 to:1024 by:2 do:[:i | s at:i put:$b].
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1100
    self assert:(s occurrencesOf:$a) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1101
    self assert:(s occurrencesOf:$b) == 512.
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1102
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1103
    "
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1104
     self new test43_occurrencesOf
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1105
    "
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1106
!
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1107
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1108
test50_indexOf
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1109
    |s i|
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1110
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1111
    s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'.
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1112
    1 to:s size do:[:start |
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1113
        i := s indexOf:$- startingAt:start.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1114
        self assert:(i == 0 or:[ i >= start]).
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1115
    ].
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1116
    "/             12345678901
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1117
    self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1118
    self assert:( 'hello world' indexOf:$l startingAt:1 ) == 3.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1119
    self assert:( 'hello world' indexOf:$l startingAt:5 ) == 10.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1120
    self assert:( 'hello world' indexOf:$d startingAt:5 ) == 11.
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1121
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1122
    "/             12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1123
    self assert:(('hello world' indexOf:$o startingAt:1) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1124
    self assert:(('hello world' indexOf:$o startingAt:2) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1125
    self assert:(('hello world' indexOf:$o startingAt:3) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1126
    self assert:(('hello world' indexOf:$o startingAt:4) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1127
    self assert:(('hello world' indexOf:$o startingAt:5) == 5).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1128
    self assert:(('hello world' indexOf:$o startingAt:6) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1129
    self assert:(('hello world' indexOf:$o startingAt:7) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1130
    self assert:(('hello world' indexOf:$o startingAt:8) == 8).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1131
    self assert:(('hello world' indexOf:$o startingAt:9) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1132
    self assert:(('hello world' indexOf:$o startingAt:10) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1133
    self assert:(('hello world' indexOf:$o startingAt:11) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1134
    self assert:(('hello world' indexOf:$o startingAt:12) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1135
    self assert:(('hello world' indexOf:$o startingAt:10000) == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1136
1418
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1137
    "/ how about 0-bytes in between
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1138
    self assert:( #[0 0 1 0 0] asString indexOf:(Character value:1) startingAt:1 ) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1139
    self assert:( #[0 0 1 0 0] asString indexOf:(Character value:0) startingAt:3 ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1140
    self assert:( #[0 0 1 1 0] asString indexOf:(Character value:0) startingAt:3 ) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1141
    self assert:( #[0 1 0 1 0] asString indexOf:(Character value:1) startingAt:3 ) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1142
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1143
    s := '12345678901234b'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1144
    self assert:(s indexOf:$x) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1145
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1146
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1147
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1148
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1149
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1150
    self assert:(s indexOf:$0) == 10.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1151
    self assert:(s indexOf:$b) == 15.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1152
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1153
    s := ''.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1154
    self assert:(s indexOf:$1) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1155
    s := '1'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1156
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1157
    self assert:(s indexOf:$2) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1158
    s := '12'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1159
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1160
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1161
    self assert:(s indexOf:$3) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1162
    s := '123'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1163
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1164
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1165
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1166
    self assert:(s indexOf:$4) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1167
    s := '1234'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1168
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1169
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1170
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1171
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1172
    self assert:(s indexOf:$5) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1173
    s := '12345'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1174
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1175
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1176
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1177
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1178
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1179
    self assert:(s indexOf:$6) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1180
    s := '123456'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1181
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1182
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1183
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1184
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1185
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1186
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1187
    self assert:(s indexOf:$7) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1188
    s := '1234567'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1189
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1190
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1191
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1192
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1193
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1194
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1195
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1196
    self assert:(s indexOf:$8) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1197
    s := '12345678'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1198
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1199
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1200
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1201
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1202
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1203
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1204
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1205
    self assert:(s indexOf:$8) == 8.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1206
    self assert:(s indexOf:$9) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1207
    s := '123456789'.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1208
    self assert:(s indexOf:$1) == 1.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1209
    self assert:(s indexOf:$2) == 2.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1210
    self assert:(s indexOf:$3) == 3.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1211
    self assert:(s indexOf:$4) == 4.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1212
    self assert:(s indexOf:$5) == 5.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1213
    self assert:(s indexOf:$6) == 6.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1214
    self assert:(s indexOf:$7) == 7.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1215
    self assert:(s indexOf:$8) == 8.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1216
    self assert:(s indexOf:$9) == 9.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1217
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1218
    self assert:(s indexOf:$0) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1219
    self assert:(s indexOf:$b) == 0.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1220
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1221
    s := String new:1024.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1222
    s atAllPut:$a.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1223
    s at:512 put:(Character space).
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1224
    self assert:(s indexOf:(Character space)) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1225
    self assert:(s indexOf:(Character space) startingAt:1) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1226
    self assert:(s indexOf:(Character space) startingAt:2) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1227
    self assert:(s indexOf:(Character space) startingAt:3) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1228
    self assert:(s indexOf:(Character space) startingAt:4) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1229
    self assert:(s indexOf:(Character space) startingAt:5) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1230
    self assert:(s indexOf:(Character space) startingAt:6) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1231
    self assert:(s indexOf:(Character space) startingAt:7) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1232
    self assert:(s indexOf:(Character space) startingAt:8) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1233
    self assert:(s indexOf:(Character space) startingAt:9) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1234
    self assert:(s indexOf:(Character space) startingAt:511) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1235
    self assert:(s indexOf:(Character space) startingAt:512) == 512.
17555e11c398 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1417
diff changeset
  1236
    self assert:(s indexOf:(Character space) startingAt:513) == 0.
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1237
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1238
    self assert:(s indexOfSeparator) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1239
    self assert:(s indexOfSeparatorStartingAt:1) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1240
    self assert:(s indexOfSeparatorStartingAt:2) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1241
    self assert:(s indexOfSeparatorStartingAt:3) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1242
    self assert:(s indexOfSeparatorStartingAt:4) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1243
    self assert:(s indexOfSeparatorStartingAt:5) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1244
    self assert:(s indexOfSeparatorStartingAt:6) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1245
    self assert:(s indexOfSeparatorStartingAt:7) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1246
    self assert:(s indexOfSeparatorStartingAt:8) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1247
    self assert:(s indexOfSeparatorStartingAt:9) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1248
    self assert:(s indexOfSeparatorStartingAt:511) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1249
    self assert:(s indexOfSeparatorStartingAt:512) == 512.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1250
    self assert:(s indexOfSeparatorStartingAt:513) == 0.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1251
571
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1252
    "
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1253
     self new test50_indexOf
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1254
    "
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1255
181f1551fa0c Additional method
Stefan Vogel <sv@exept.de>
parents: 570
diff changeset
  1256
    "Created: / 29-10-2010 / 14:58:21 / cg"
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1257
    "Modified: / 02-04-2019 / 11:06:52 / Claus Gittinger"
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1258
!
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1259
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1260
test51_substrings
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1261
    self assert:('aaa/bbb/ccc' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc').
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1262
    self assert:(('aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = 'aaa/bbb/ccc'.
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1263
2083
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1264
    self assert:('aaa/bbb' withoutSuffix:'bbb') = 'aaa/'.
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1265
    self assert:('aaa/bbb' withoutPrefix:'aaa') = '/bbb'.
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1266
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1267
"/    self assert:('/aaa/bbb/ccc' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1268
"/    self assert:(('/aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1269
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1270
"/    self assert:('aaa/bbb/ccc/' subStrings:'/') asArray = #('aaa' 'bbb' 'ccc' '' ).
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1271
"/    self assert:(('aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc/'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1272
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1273
"/    self assert:('/aaa/bbb/ccc/' subStrings:'/') asArray = #('' 'aaa' 'bbb' 'ccc' '').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1274
"/    self assert:(('/aaa/bbb/ccc/' subStrings:'/') asStringWith:'/') = '/aaa/bbb/ccc'' '.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1275
"/
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1276
"/    self assert:('//aaa/bbb/ccc' subStrings:'/') asArray = #('' '' 'aaa' 'bbb' 'ccc').
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1277
"/    self assert:(('//aaa/bbb/ccc' subStrings:'/') asStringWith:'/') = '//aaa/bbb/ccc'.
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1278
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1279
    "
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1280
     self new test51_substrings
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1281
    "
2083
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1282
fd47bd71202f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1283
    "Modified: / 11-02-2019 / 23:57:03 / Claus Gittinger"
1373
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1284
!
92c28dfbf621 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1285
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1286
test52_indexOfSeparator
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1287
    |j s|
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1288
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1289
    self assert:('' indexOfSeparator) == 0.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1290
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1291
	s := (String new:n withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1292
	1 to:20 do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1293
	    self assert:(s indexOfSeparatorStartingAt:start) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1294
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1295
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1296
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1297
	s := (String new:n withAll:$a),' '.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1298
	1 to:n do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1299
	    self assert:(s indexOfSeparatorStartingAt:start) == (n+1).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1300
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1301
    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1302
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1303
    {
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1304
	Character space .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1305
	Character tab .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1306
	Character return .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1307
	Character lf .
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1308
    } do:[:sep |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1309
	1 to:20 do:[:na |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1310
	    1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1311
		s := (String new:na withAll:$a),sep,(String new:na withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1312
		1 to:na do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1313
		    self assert:(s indexOfSeparatorStartingAt:start) == (na+1).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1314
		]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1315
	    ]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1316
	].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1317
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1318
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1319
    {
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1320
	Character esc .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1321
	Character null .
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1322
	$a .
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1323
    } do:[:nonSep |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1324
	1 to:20 do:[:na |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1325
	    1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1326
		s := (String new:na withAll:$a),nonSep,(String new:na withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1327
		1 to:20 do:[:start |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1328
		    self assert:(s indexOfSeparatorStartingAt:start) == 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1329
		]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1330
	    ]
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1331
	].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1332
    ].
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1333
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1334
    s := String new:1000 withAll:$a.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1335
    self assert:(s indexOfSeparatorStartingAt:1) == 0.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1336
    400 to: 417 do:[:i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1337
	s := String new:1000 withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1338
	s at:i put:(Character space).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1339
	self assert:(s indexOfSeparatorStartingAt:1) == i.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1340
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1341
	s := String new:1000 withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1342
	s at:i put:(Character return).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1343
	self assert:(s indexOfSeparatorStartingAt:1) == i.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1344
    ].
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1345
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1346
      "/  12345678901
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1347
    j := 'hello world' indexOfSeparatorStartingAt:1.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1348
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1349
    j := 'hello world ' indexOfSeparatorStartingAt:2.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1350
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1351
    j := 'hello world ' indexOfSeparatorStartingAt:3.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1352
    self assert:(j == 6).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1353
    j := 'hello world ' indexOfSeparatorStartingAt:4.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1354
    self assert:(j == 6).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1355
    j := 'hello world ' indexOfSeparatorStartingAt:5.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1356
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1357
    j := 'hello world ' indexOfSeparatorStartingAt:6.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1358
    self assert:(j == 6).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1359
    j := 'hello world ' indexOfSeparatorStartingAt:7.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1360
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1361
    j := 'hello world ' indexOfSeparatorStartingAt:8.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1362
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1363
    j := 'hello world ' indexOfSeparatorStartingAt:9.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1364
    self assert:(j == 12).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1365
    j := 'hello world ' indexOfSeparatorStartingAt:10.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1366
    self assert:(j == 12).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1367
    j := 'hello world ' indexOfSeparatorStartingAt:11.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1368
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1369
    j := 'hello world ' indexOfSeparatorStartingAt:12.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1370
    self assert:(j == 12).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1371
    j := 'hello world' indexOfSeparatorStartingAt:12.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1372
    self assert:(j == 0).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1373
    j := 'hello world ' indexOfSeparatorStartingAt:13.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1374
    self assert:(j == 0).
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1375
    j := 'hello world ' indexOfSeparatorStartingAt:10000.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1376
    self assert:(j == 0).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1377
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1378
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1379
     self new test52_indexOfSeparator
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1380
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1381
!
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1382
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1383
test54_occurrencesOf
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1384
    |s|
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1385
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1386
    self assert:('' occurrencesOf:$a) == 0.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1387
    1 to:20 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1388
	s := (String new:n withAll:$a).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1389
	self assert:(s occurrencesOf:$a) == n.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1390
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1391
    1 to:20 do:[:na |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1392
	1 to:20 do:[:nb |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1393
	    s := (String new:na withAll:$a),(String new:nb withAll:$b).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1394
	    self assert:(s occurrencesOf:$a) == na.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1395
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1396
    ].
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1397
    1 to:40 do:[:n |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1398
	s := String new:n withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1399
	1 to:n by:2 do:[:n |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1400
	    s at:n put:$b.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1401
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1402
	self assert:(s occurrencesOf:$a) == (n // 2).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1403
    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1404
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1405
    s := String new:1000 withAll:$a.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1406
    self assert:(s occurrencesOf:$a) == 1000.
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1407
    1 to:1000 do:[:i |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1408
	s at:i put:$b.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1409
	self assert:(s occurrencesOf:$a) == (1000-i).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1410
	self assert:(s occurrencesOf:$b) == i.
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1411
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1412
1420
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1413
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1414
     self new test54_occurrencesOf
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1415
    "
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1416
!
d5438e5960ed #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1417
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1418
test60a_hash
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1419
    "
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1420
    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
  1421
    returned different values. This test checks this
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1422
    "
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1423
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1424
    | tester |
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1425
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1426
    tester := [:s|
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1427
        |sHash u16Hash u32Hash|
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1428
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1429
        sHash := s hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1430
        u16Hash := s asUnicode16String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1431
        u32Hash := s asUnicode32String hash.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1432
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1433
        self assert: sHash == u16Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1434
             description: ('String and Unicode16String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1435
                                bindWith:s with:s class name).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1436
        self assert: sHash == u32Hash
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1437
             description: ('String and Unicode32String hashes differ on "%1" (%2)'
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1438
                                bindWith:s with:s class name)
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1439
    ].
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1440
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1441
    tester value:'a'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1442
    tester value:'123456789012345678'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1443
    tester value:'12345678901234567'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1444
    tester value:'1234567890123456'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1445
    tester value:'123456789012345'.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1446
    tester value:'12345678901234'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1447
    tester value:'1234567890123'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1448
    tester value:'123456789012'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1449
    tester value:'12345678901'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1450
    tester value:'1234567890'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1451
    tester value:'123456789'.
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1452
    tester value:'12345678'.
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1453
    tester value:'1234567'.
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1454
    tester value:'123456'.
1385
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1455
    tester value:'12345'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1456
    tester value:'1234'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1457
    tester value:'123'.
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
  1458
    tester value:'12'.
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1459
    tester value:'boolean'.
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1460
1417
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1461
    "/ strings with 0-elements
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1462
    tester value:('' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1463
    tester value:('1' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1464
    tester value:('12' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1465
    tester value:('123' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1466
    tester value:('1234' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1467
    tester value:('12345' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1468
    tester value:('123456' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1469
    tester value:('1234567' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1470
    tester value:('12345678' copyWith:Character null).
d624843fda05 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1389
diff changeset
  1471
    tester value:('123456789' copyWith:Character null).
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1472
    tester value:('1234567890' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1473
    tester value:('12345678901' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1474
    tester value:('123456789012' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1475
    tester value:('1234567890123' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1476
    tester value:('12345678901234' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1477
    tester value:('123456789012345' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1478
    tester value:('1234567890123456' copyWith:Character null).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1479
    tester value:('12345678901234567' copyWith:Character null).
1419
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1480
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1481
    tester value:('' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1482
    tester value:('1' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1483
    tester value:('12' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1484
    tester value:('123' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1485
    tester value:('1234' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1486
    tester value:('12345' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1487
    tester value:('123456' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1488
    tester value:('1234567' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1489
    tester value:('12345678' copyWith:Character null),'123'.
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1490
    tester value:('123456789' copyWith:Character null),'123'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1491
    tester value:('1234567890' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1492
    tester value:('12345678901' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1493
    tester value:('123456789012' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1494
    tester value:('1234567890123' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1495
    tester value:('12345678901234' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1496
    tester value:('123456789012345' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1497
    tester value:('1234567890123456' copyWith:Character null),'123'.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1498
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1499
    "Created: / 02-04-2019 / 10:55:23 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1500
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1501
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1502
test60b_hash
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1503
    "verifies that symbols hash the same as string, u16string and u32string"
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1504
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1505
    | tester |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1506
2212
80b766225587 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2211
diff changeset
  1507
    "/ self skip:'takes long'.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1508
    
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1509
    tester := [:s|
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1510
        |sHash u8Hash u16Hash u32Hash|
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1511
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1512
        sHash := s hash.
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1513
        u8Hash := s asString hash.
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1514
        u16Hash := s asUnicode16String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1515
        u32Hash := s asUnicode32String hash.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1516
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1517
        self assert: sHash == u8Hash
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1518
             description: ('Symbol and String hashes differ on "%1" (%2)'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1519
                                bindWith:s with:s class name).
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1520
        self assert: sHash == u16Hash
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1521
             description: ('Symbol and Unicode16String hashes differ on "%1" (%2)'
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1522
                                bindWith:s with:s class name).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1523
        self assert: sHash == u32Hash
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  1524
             description: ('Symbol and Unicode32String hashes differ on "%1" (%2)'
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1525
                                bindWith:s with:s class name)
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1526
    ].
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1527
1419
cfc3eb59fbcf #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1528
    "/ String allInstancesDo:[:each| tester value:each].
753
81af28f807cf class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 752
diff changeset
  1529
    Symbol allInstancesDo:[:each| tester value:each].
751
8c9ff6c5efe2 Added string hashing tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 702
diff changeset
  1530
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1531
    "Created: / 02-04-2019 / 10:55:26 / Claus Gittinger"
962
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1532
!
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1533
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1534
test61_hash
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1535
    "all string-representations must hash equal"
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1536
    
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1537
    | string8 string16 string32 |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1538
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1539
    string8 := 'sun/nio/cs/UTF_8.class'.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1540
    string16 := string8 asUnicode16String.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1541
    string32 := string8 asUnicode16String.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1542
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1543
    self assert: string8 hash == string16 hash.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1544
    self assert: string8 hash == string32 hash.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1545
    self assert: string8 hash == string8 asSymbol hash.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1546
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1547
    "Created: / 09-10-2014 / 12:41:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1548
    "Modified: / 02-04-2019 / 10:42:35 / Claus Gittinger"
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1549
!
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  1550
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1551
test65_concatenation
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1552
    |strA strB|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1553
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1554
    0 to:32 do:[:szA |
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1555
        0 to:32 do:[:szB |
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1556
            |szAB|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1557
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1558
            strA := String new:szA withAll:$a.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1559
            strB := String new:szB withAll:$b.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1560
            szAB := szA + szB.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1561
            self assert:(szA = strA size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1562
            self assert:(szB = strB size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1563
            "/ why repeat ??? - to check GC???
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1564
            1 "10000" timesRepeat:[
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1565
                |strAB|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1566
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1567
                strAB := strA , strB.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1568
                self assert:(szAB == strAB size).
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1569
            ]
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1570
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1571
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1572
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1573
    strA := strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1574
    self assert: ((strA , strB) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1575
    self assert: ((strA , strA) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1576
    strA := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1577
    self assert: ((strA , strA) = 'aa').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1578
    self assert: ((strA , strB) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1579
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1580
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1581
    self assert: ((strA , strB) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1582
    strA := 'b'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1583
    strB := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1584
    self assert: ((strB , strA) = 'ab').
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1585
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1586
    "/ concatenating other things
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1587
    self assert:('hello',123) = 'hello123'.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1588
    self assert:('hello' asUnicode16String,123) = 'hello123' asUnicode16String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1589
    self assert:('hello' asUnicode32String,123) = 'hello123' asUnicode32String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1590
    
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1591
    "/ concatenating other things
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1592
    self assert:('hello',,123) = c'hello\n123'.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1593
    self assert:('hello' asUnicode16String,,123) = c'hello\n123' asUnicode16String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1594
    self assert:('hello' asUnicode32String,,123) = c'hello\n123' asUnicode32String.
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1595
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1596
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1597
     self new test65_concatenation
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1598
    "
2207
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1599
33fec8c61cb8 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2112
diff changeset
  1600
    "Modified: / 02-04-2019 / 10:41:24 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1601
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1602
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1603
test66_replace
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1604
    |strA|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1605
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1606
    1 to:64 do:[:szA |
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1607
	strA := String new:szA withAll:$a.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1608
	    1 to:szA do:[:idx |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1609
		strA at:idx put:$*.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1610
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1611
		strA replaceAll:$* with:$#.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1612
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1613
		self assert:(strA at:idx) = $#.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1614
		self assert:(strA occurrencesOf:$#) = idx.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1615
		self assert:(strA count:[:ch | ch = $#]) = idx.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1616
		self assert:(strA occurrencesOf:$*) = 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1617
		self assert:(strA count:[:ch | ch = $*]) = 0.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1618
		self assert:(strA includes:$#).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1619
		self assert:(strA includes:$*) not.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1620
	]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1621
    ]
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1622
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1623
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1624
     self new test66_replace
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1625
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1626
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1627
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1628
test67_concatenationAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1629
    |strA strB strC|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1630
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1631
    0 to:32 do:[:szA |
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1632
        0 to:32 do:[:szB |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1633
            0 to:32 do:[:szC |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1634
                |szABC|
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1635
                strA := String new:szA withAll:$a.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1636
                strB := String new:szB withAll:$b.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1637
                strC := String new:szC withAll:$c.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1638
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1639
                szABC := szA + szB + szC.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1640
                self assert:(szA = strA size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1641
                self assert:(szB = strB size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1642
                self assert:(szC = strC size).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1643
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1644
                "/ why repeat? to test GC???
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1645
                1 "300" timesRepeat:[
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1646
                    |strABC|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1647
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1648
                    strABC := strA concatenate:strB and:strC.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1649
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1650
                    self assert:(szABC == strABC size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1651
                ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1652
            ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1653
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1654
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1655
    strA := strB := strC := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1656
    self assert: ((strA concatenate:strB and:strC) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1657
    strA := 'a'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1658
    self assert: ((strA concatenate:strB and:strC) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1659
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1660
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1661
    self assert: ((strA concatenate:strB and:strC) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1662
    strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1663
    strC := 'c'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1664
    self assert: ((strA concatenate:strB and:strC) = 'c').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1665
    strA := 'c'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1666
    strB := 'b'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1667
    strC := 'a'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1668
    self assert: ((strC concatenate:strB and:strA) = 'abc').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1669
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1670
     self new test67_concatenationAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1671
    "
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1672
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1673
    "Modified: / 02-04-2019 / 10:51:31 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1674
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1675
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1676
test68_concatenationAndAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1677
    |strA strB strC strD|
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1678
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1679
    0 to:32 do:[:szA |
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1680
        strA := String new:szA withAll:$a.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1681
        self assert:(szA = strA size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1682
        0 to:32 do:[:szB |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1683
            strB := String new:szB withAll:$b.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1684
            self assert:(szB = strB size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1685
            0 to:32 do:[:szC |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1686
                strC := String new:szC withAll:$c.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1687
                self assert:(szC = strC size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1688
                0 to:32 do:[:szD |
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1689
                    |szABCD|
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1690
                    strD := String new:szD withAll:$d.
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1691
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1692
                    szABCD := szA + szB + szC + szD.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1693
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1694
                    self assert:(szD = strD size).
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1695
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1696
                    "/ why repeat???
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1697
                    1 "5" timesRepeat:[
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1698
                        |strABCD|
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1699
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1700
                        strABCD := strA concatenate:strB and:strC and:strD.
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1701
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1702
                        self assert:(szABCD == strABCD size).
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1703
                    ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1704
                ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1705
            ]
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1706
        ]
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1707
    ].
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1708
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1709
    strA := strB := strC := strD := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1710
    self assert: ((strA concatenate:strB and:strC and:strD) = '').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1711
    strA := 'a'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1712
    self assert: ((strA concatenate:strB and:strC and:strD) = 'a').
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1713
    strA := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1714
    strB := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1715
    self assert: ((strA concatenate:strB and:strC and:strD) = 'b').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1716
    strB := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1717
    strC := 'c'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1718
    self assert: ((strA concatenate:strB and:strC and:strD) = 'c').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1719
    strC := ''.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1720
    strD := 'd'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1721
    self assert: ((strA concatenate:strB and:strC and:strD) = 'd').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1722
    strA := 'd'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1723
    strB := 'c'.
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1724
    strC := 'b'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1725
    strD := 'a'.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1433
diff changeset
  1726
    self assert: ((strD concatenate:strC and:strB and:strA) = 'abcd').
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1727
    "
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1728
     self new test68_concatenationAndAnd
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1729
    "
2210
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1730
d3368bb7f119 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2209
diff changeset
  1731
    "Modified: / 02-04-2019 / 10:51:50 / Claus Gittinger"
1426
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1732
!
f9427fb3fbcf #QUALITY by mawalch
mawalch
parents: 1425
diff changeset
  1733
1991
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1734
test69_split
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1735
    self assert:(('a,b,c,d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1736
    self assert:(('a;b;c;d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1737
    self assert:(('a;b,c;d' splitByAny:',;') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1738
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1739
    self assert:(($, split:'a,b,c,d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1740
    self assert:((',' split:'a,b,c,d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1741
    self assert:(('//' split:'a//b//c//d') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1742
    self assert:(('a//b//c//d' splitOn:'//') sameContentsAs: #('a' 'b' 'c' 'd')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1743
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1744
    "/ self assert:(([:ch | ch isLetter] split:'a2b3c4') sameContentsAs: #('1' '2' '3' '4')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1745
    "/ self assert:(([:char | char isDigit] split: '1a2b3c4') sameContentsAs: #('a' 'b' 'c')).
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1746
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1747
    "
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1748
     self new test69_split
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1749
    "
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1750
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1751
    "Created: / 20-07-2018 / 23:54:15 / Claus Gittinger"
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1752
!
522d8744231d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1990
diff changeset
  1753
962
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1754
test70_storeString
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1755
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1756
    self assert: 'AAA' storeString = '''AAA'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1757
    self assert: 'A''A''A' storeString = '''A''''A''''A'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1758
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1759
    self assert: 'AAA' asImmutableString storeString = '''AAA'''.
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1760
    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
  1761
2fca937dc59b class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 874
diff changeset
  1762
    "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
  1763
!
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1764
2465
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1765
test80a_copyReplaceAll
1103
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1766
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1767
    | orig copy |
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1768
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1769
    orig := 'AAA' copy. "/ In case literals are immutable...
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1770
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1771
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1772
    copy := orig copyReplaceAll: $A with: $X.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1773
    self assert: copy = 'XXX'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1774
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1775
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1776
    orig := 'AAA' asImmutableString.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1777
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1778
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1779
    copy := orig copyReplaceAll: $A with: $X.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1780
    self assert: copy = 'XXX'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1781
    self assert: orig = 'AAA'.
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1782
373c0f5e539d class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1060
diff changeset
  1783
    "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
  1784
!
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  1785
2465
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1786
test80b_copyReplaceString
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1787
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1788
    | copy |
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1789
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1790
    copy := 'AAA' copyReplaceString:'AA' withString:'BB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1791
    self assert: copy = 'BBA'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1792
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1793
    copy := 'AAAA' copyReplaceString:'AA' withString:'BB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1794
    self assert: copy = 'BBBB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1795
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1796
    copy := 'AAAA' copyReplaceString:'XX' withString:'BB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1797
    self assert: copy = 'AAAA'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1798
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1799
    copy := '' copyReplaceString:'XX' withString:'BB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1800
    self assert: copy = ''.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1801
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1802
    copy := 'X' copyReplaceString:'XX' withString:'BB'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1803
    self assert: copy = 'X'.
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1804
!
dafd40caecba #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2393
diff changeset
  1805
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1806
test81_filling
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1807
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1808
    | str |
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1809
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1810
    str := 'AAA' copy. "/ In case literals are immutable...
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1811
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1812
    str atAllPut:$B.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1813
    self assert: str = 'BBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1814
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1815
    str from:1 to:0 put:$C.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1816
    self assert: str = 'BBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1817
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1818
    str from:1 to:1 put:$D.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1819
    self assert: str = 'DBB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1820
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1821
    str from:1 to:2 put:$E.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1822
    self assert: str = 'EEB'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1823
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1824
    str from:1 to:3 put:$F.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1825
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1826
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1827
    str from:1 to:0 put:$G.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1828
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1829
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1830
    str from:-1 to:-2 put:$G.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1831
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1832
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1833
    self should:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1834
	str from:-1 to:-1 put:$x
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1835
    ] raise:SubscriptOutOfBoundsError.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1836
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1837
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1838
    self should:[
1421
3236b9c7d993 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
  1839
	str from:-1 to:1 put:$x
1240
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1840
    ] raise:SubscriptOutOfBoundsError.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1841
    self assert: str = 'FFF'.
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1842
!
4b187f56458b class: RegressionTests::StringTests
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
  1843
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1844
test82a_expanding
2077
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1845
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1846
    | rslt |
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1847
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1848
    rslt := 'A%1B%2C' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1849
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1850
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1851
    rslt := 'A%1B%2C%' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1852
    self assert:(rslt = 'A10B20C%').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1853
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1854
    rslt := 'A%%1B%2C%' expandPlaceholdersWith:#(10 20 30).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1855
    self assert:(rslt = 'A%1B20C%').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1856
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1857
    
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1858
    rslt := 'A%aB%bC' expandPlaceholdersWith:(Dictionary withKeys:#(a b c)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1859
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1860
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1861
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1862
    "/ not expanded, if not found
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1863
    rslt := 'A%aB%bC' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1864
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1865
    self assert:(rslt = 'A%aB%bC').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1866
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1867
    rslt := 'A%aaB%bbC' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1868
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1869
    self assert:(rslt = 'A%aaB%bbC').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1870
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1871
    rslt := 'A%(aa)B%(bb)C' expandPlaceholdersWith:(Dictionary withKeys:#(aa bb cc)
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1872
                                                         andValues:#(10 20 30)).
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1873
    self assert:(rslt = 'A10B20C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1874
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1875
    "/ allowing non-parenthized 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1876
    rslt := String streamContents:[:s |
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1877
                'A%aa,B%bb,C' 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1878
                        expandPlaceholders:$%
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1879
                        with:(Dictionary withKeys:#(aa bb cc) andValues:#(10 20 30))
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1880
                        ignoreNumericEscapes:false 
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1881
                        requireParentheses:false
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1882
                        on:s.
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1883
            ].
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1884
    self assert:(rslt = 'A10,B20,C').
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1885
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1886
    "Created: / 02-04-2019 / 11:00:08 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1887
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1888
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1889
test82b_expanding
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1890
    | rslt |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1891
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1892
    rslt := 'hello' copyExpanding:(Dictionary 
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1893
                                        withKeys:{$h . $e . $o} 
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1894
                                        andValues:{'HH' . 'EE' . $O }).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1895
    self assert:(rslt = 'HHEEllO').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1896
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1897
    rslt := 'he%2llo%1' % { 123 . 456 }.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1898
    self assert:(rslt = 'he456llo123').
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1899
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1900
    "Created: / 02-04-2019 / 11:00:43 / Claus Gittinger"
2077
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1901
!
a8fde1ea4970 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1991
diff changeset
  1902
2327
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1903
test82c_expanding
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1904
    | rslt |
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1905
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1906
    rslt := '%1-%2-%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1907
            expandPlaceholders:$$
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1908
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1909
            ignoreNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1910
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1911
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1912
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1913
    self assert:(rslt = '%1-%2-%3').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1914
2328
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1915
    rslt := '$$rev'
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1916
            expandPlaceholders:$$
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1917
            with:{10 . 20 . 30}
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1918
            ignoreNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1919
            ignoreNonNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1920
            ignoreSpecialEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1921
            requireParentheses:false.
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1922
    self assert:(rslt = '$rev').
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1923
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1924
    rslt := '$$rev'
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1925
            expandPlaceholders:$$
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1926
            with:(Dictionary withKeysAndValues:{ 'rev' . '1234'})
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1927
            ignoreNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1928
            ignoreNonNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1929
            ignoreSpecialEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1930
            requireParentheses:false.
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1931
    self assert:(rslt = '$rev').
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1932
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1933
    rslt := '$rev'
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1934
            expandPlaceholders:$$
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1935
            with:{10 . 20 . 30}
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1936
            ignoreNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1937
            ignoreNonNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1938
            ignoreSpecialEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1939
            requireParentheses:false.
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1940
    self assert:(rslt = '$rev').
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1941
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1942
    rslt := '$rev'
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1943
            expandPlaceholders:$$
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1944
            with:(Dictionary withKeysAndValues:{ 'rev' . '1234'})
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1945
            ignoreNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1946
            ignoreNonNumericEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1947
            ignoreSpecialEscapes:false
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1948
            requireParentheses:false.
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1949
    self assert:(rslt = '1234').
cfee3c8c8f98 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2327
diff changeset
  1950
2327
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1951
    rslt := '%1-%2-%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1952
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1953
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1954
            ignoreNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1955
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1956
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1957
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1958
    self assert:(rslt = '10-20-30').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1959
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1960
    rslt := '%1-%2-%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1961
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1962
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1963
            ignoreNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1964
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1965
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1966
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1967
    self assert:(rslt = '%1-%2-%3').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1968
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1969
    rslt := '%1%<cr>%2%<cr>%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1970
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1971
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1972
            ignoreNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1973
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1974
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1975
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1976
    self assert:(rslt = c'%1\n%2\n%3').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1977
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1978
    rslt := '%1%<cr>%2%<cr>%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1979
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1980
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1981
            ignoreNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1982
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1983
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1984
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1985
    self assert:(rslt = c'10\n20\n30').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1986
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1987
    rslt := '%1%<cr>%2%<cr>%3'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1988
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1989
            with:{10 . 20 . 30}
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1990
            ignoreNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1991
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1992
            ignoreSpecialEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1993
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1994
    self assert:(rslt = '10%<cr>20%<cr>30').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1995
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1996
    rslt := '%1 %(a) %(1) %(b)'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1997
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1998
            with:(Dictionary withKeysAndValues:{ 'a' . 'AAA' . 'b' . 'BBB' })
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  1999
            ignoreNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2000
            ignoreNonNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2001
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2002
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2003
    self assert:(rslt = ' %(a)  %(b)').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2004
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2005
    rslt := '%1 %(a) %(1) %(b)'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2006
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2007
            with:(Dictionary withKeysAndValues:{ 'a' . 'AAA' . 'b' . 'BBB' })
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2008
            ignoreNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2009
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2010
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2011
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2012
    self assert:(rslt = '%1 AAA %(1) BBB').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2013
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2014
    rslt := '%1 %a %(1) %b'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2015
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2016
            with:(Dictionary withKeysAndValues:{ 'a' . 'AAA' . 'b' . 'BBB' })
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2017
            ignoreNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2018
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2019
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2020
            requireParentheses:false.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2021
    self assert:(rslt = '%1 AAA %(1) BBB').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2022
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2023
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2024
    rslt := '%1 %aa %(1) %bb'
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2025
            expandPlaceholders:$%
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2026
            with:(Dictionary withKeysAndValues:{ 'a' . 'AAA' . 'b' . 'BBB' })
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2027
            ignoreNumericEscapes:true
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2028
            ignoreNonNumericEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2029
            ignoreSpecialEscapes:false
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2030
            requireParentheses:true.
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2031
    self assert:(rslt = '%1 AAAa %(1) BBBb').
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2032
!
bf482d49aeaf #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2242
diff changeset
  2033
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2034
test82d_expanding
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2035
    "what happens with missing keys:"
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2036
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2037
    | rslt |
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2038
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2039
    rslt := '%1-%2-%3'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2040
            expandPlaceholders:$%
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2041
            with:{10 . 20 }
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2042
            ignoreNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2043
            ignoreNonNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2044
            ignoreSpecialEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2045
            requireParentheses:false.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2046
    self assert:(rslt = '10-20-').
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2047
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2048
    "/ stupid backward compatibiliy!!
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2049
    rslt := '%a-%b-%c'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2050
            expandPlaceholders:$%
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2051
            with:(Dictionary withKeys:#('a' 'b') andValues:#(10 20 ))
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2052
            ignoreNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2053
            ignoreNonNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2054
            ignoreSpecialEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2055
            requireParentheses:false.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2056
    self assert:(rslt = '10-20-%c').
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2057
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2058
    rslt := '%(a)-%(b)-%(c)'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2059
            expandPlaceholders:$%
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2060
            with:(Dictionary withKeys:#('a' 'b') andValues:#(10 20 ))
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2061
            ignoreNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2062
            ignoreNonNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2063
            ignoreSpecialEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2064
            requireParentheses:false.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2065
    self assert:(rslt = '10-20-').
2378
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2066
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2067
    rslt := '%(a)-%(b)-%(c)'
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2068
            expandPlaceholders:$%
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2069
            with:(Dictionary withKeys:#('a' 'b') andValues:#(10 20 ))
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2070
            ignoreNumericEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2071
            ignoreNonNumericEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2072
            ignoreSpecialEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2073
            requireParentheses:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2074
            ifKeyAbsent:[:str :var | str].
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2075
    self assert:(rslt = '10-20-%(c)').
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2076
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2077
    rslt := '%(a)-%(b)-%(abc)'
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2078
            expandPlaceholders:$%
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2079
            with:(Dictionary withKeys:#('a' 'b') andValues:#(10 20 ))
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2080
            ignoreNumericEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2081
            ignoreNonNumericEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2082
            ignoreSpecialEscapes:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2083
            requireParentheses:false
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2084
            ifKeyAbsent:[:str :var | str].
789f2fc52c57 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2377
diff changeset
  2085
    self assert:(rslt = '10-20-%(abc)').
2377
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2086
!
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2087
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2088
test82e_expandingSpecialSequences
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2089
    | rslt |
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2090
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2091
    rslt := 'abc%<tab>def'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2092
            expandPlaceholders:$%
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2093
            with:nil
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2094
            ignoreNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2095
            ignoreNonNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2096
            ignoreSpecialEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2097
            requireParentheses:false.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2098
    self assert:(rslt = ('abc',Character tab,'def')).
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2099
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2100
    rslt := 'abc%<crlf>def'
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2101
            expandPlaceholders:$%
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2102
            with:nil
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2103
            ignoreNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2104
            ignoreNonNumericEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2105
            ignoreSpecialEscapes:false
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2106
            requireParentheses:false.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2107
    self assert:(rslt = ('abc',String crlf,'def')).
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2108
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2109
    rslt := 'abc%<crlf>def' with:nil.
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2110
    self assert:(rslt = ('abc',String crlf,'def')).
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2111
!
e730910ab2a5 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2365
diff changeset
  2112
2388
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2113
test82f_expanding
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2114
    "special cases:"
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2115
2389
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2116
    | rslt args |
2388
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2117
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2118
    rslt := '%' bindWith:'aaa'.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2119
    self assert:(rslt = '%').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2120
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2121
    rslt := '%1' bindWith:'aaa'.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2122
    self assert:(rslt = 'aaa').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2123
    rslt := '%1b' bindWith:'aaa'.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2124
    self assert:(rslt = 'aaab').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2125
    rslt := '%2' bindWith:'aaa'.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2126
    self assert:(rslt = '').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2127
    rslt := '%9' bindWith:'aaa'.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2128
    self assert:(rslt = '').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2129
    rslt := '%9' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9).  
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2130
    self assert:(rslt = 'i9').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2131
    rslt := '%1x' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2132
    self assert:(rslt = 'a1x').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2133
    rslt := '%10' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2134
    self assert:(rslt = 'j10').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2135
    rslt := '%10x' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2136
    self assert:(rslt = 'j10x').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2137
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2138
    rslt := 'hello %10%9%8' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2139
    self assert:(rslt = 'hello x10x9x8').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2140
    rslt := 'hello %10' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2141
    self assert:(rslt = 'hello x10').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2142
    rslt := 'hello %(1)x' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2143
    self assert:(rslt = 'hello x1x').
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2144
2389
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2145
    args := Dictionary new
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2146
                at:'year' put:'yyyy';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2147
                at:'mon' put:'mmm';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2148
                at:'day' put:'dd';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2149
                at:'h' put:'HH';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2150
                at:'m' put:'MM';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2151
                at:'s' put:'SS';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2152
                at:'i' put:'II';
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2153
                yourself.
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2154
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2155
    rslt := '%(year)-%(mon)-%(day) %h:%m:%s.%i' bindWithArguments:args.
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2156
    self assert:(rslt = 'yyyy-mmm-dd HH:MM:SS.II').
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2157
    rslt := '%(year)-%(mon)-%(day) %(h):%(m):%(s).%(i)' bindWithArguments:args.
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2158
    self assert:(rslt = 'yyyy-mmm-dd HH:MM:SS.II').
481588f3ca33 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2388
diff changeset
  2159
2388
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2160
    self should:[ rslt := '%(' bindWith:'aaa' ] raise:Error.
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2161
!
6ac280a6d988 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
  2162
2112
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2163
test83_padding
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2164
    | rslt |
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2165
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2166
    rslt := 'foo' paddedTo:10.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2167
    self assert:(rslt = 'foo       ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2168
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2169
    rslt := 'foo' paddedTo:3.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2170
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2171
    rslt := 'foo' paddedTo:4.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2172
    self assert:(rslt = 'foo ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2173
    rslt := 'foo' paddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2174
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2175
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2176
    rslt := '' paddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2177
    self assert:(rslt = '  ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2178
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2179
    rslt := 'foo' paddedTo:10 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2180
    self assert:(rslt = 'foo-------').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2181
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2182
    rslt := 'foo' paddedTo:3 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2183
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2184
    rslt := 'foo' paddedTo:4 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2185
    self assert:(rslt = 'foo-').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2186
    rslt := 'foo' paddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2187
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2188
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2189
    rslt := '' paddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2190
    self assert:(rslt = '--').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2191
    
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2192
    rslt := 'foo' leftPaddedTo:10.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2193
    self assert:(rslt = '       foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2194
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2195
    rslt := 'foo' leftPaddedTo:3.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2196
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2197
    rslt := 'foo' leftPaddedTo:4.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2198
    self assert:(rslt = ' foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2199
    rslt := 'foo' leftPaddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2200
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2201
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2202
    rslt := '' leftPaddedTo:2.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2203
    self assert:(rslt = '  ').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2204
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2205
    rslt := 'foo' leftPaddedTo:10 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2206
    self assert:(rslt = '-------foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2207
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2208
    rslt := 'foo' leftPaddedTo:3 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2209
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2210
    rslt := 'foo' leftPaddedTo:4 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2211
    self assert:(rslt = '-foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2212
    rslt := 'foo' leftPaddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2213
    self assert:(rslt = 'foo').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2214
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2215
    rslt := '' leftPaddedTo:2 with:$-.
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2216
    self assert:(rslt = '--').
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2217
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2218
    "Created: / 21-03-2019 / 12:58:33 / Claus Gittinger"
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2219
!
3e51f70c1b03 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2083
diff changeset
  2220
2211
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2221
test84_withCRs
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2222
    | rslt |
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2223
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2224
    rslt := 'foo\bar' addLineDelimiters.
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2225
    self assert:(rslt = ('foo',Character cr,'bar')).
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2226
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2227
    "Created: / 02-04-2019 / 10:57:44 / Claus Gittinger"
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2228
!
632cea1b911c #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  2229
2393
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2230
test85_printf
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2231
    self assert:( (PrintfScanf printf:'%c' argument:$a) = 'a' ).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2232
    self assert:( (PrintfScanf printf:'%c' argument:'a') = 'a' ).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2233
    self assert:( (PrintfScanf printf:'%c' argument:'abc') = 'a' ).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2234
    self assert:( (PrintfScanf printf:'%c' argument:65) = 'A' ).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2235
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2236
    "/ verify that our printf generates the same string as the system-printf.
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2237
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2238
    #(
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2239
        '%s'       ''           ''  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2240
        '%s'       'abc'        'abc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2241
        'x%s'      ''           'x'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2242
        'x%s'      'abc'        'xabc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2243
        '%sx'      ''           'x'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2244
        '%sx'      'abc'        'abcx'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2245
        'x%sx'     ''           'xx'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2246
        'x%sx'     'abc'        'xabcx'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2247
        '%6s'      'abc'        '   abc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2248
        '%-6s'     'abc'        'abc   '  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2249
     "/   '%06s'     'abc'        '000abc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2250
     "/   '%-06s'    'abc'        'abc000' 
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2251
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2252
        '%.3s'     'abcdef'     'abc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2253
        '%6.3s'    'abcdef'     '   abc'  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2254
        '%-6.3s'   'abcdef'     'abc   '  
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2255
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2256
    ) inGroupsOf:3 do:[:fmt :val :expected|
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2257
        |printfGenerated stxGenerated|
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2258
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2259
        printfGenerated := val printfPrintString:fmt.
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2260
        stxGenerated := PrintfScanf printf:fmt argument:val.
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2261
        self assert:(stxGenerated = printfGenerated).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2262
        self assert:(printfGenerated = expected).
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2263
    ].
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2264
!
96f3b2a65ead #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
  2265
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2266
test90_enumeratingLines
2208
2d54a6ac9a73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2267
    
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2268
    |  |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2269
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2270
    #(
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2271
        c''
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2272
        c'abc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2273
        c'\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2274
        c'abc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2275
        c'\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2276
        c'abc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2277
        c'\n\nabc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2278
        c'\nabc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2279
        c'abc\nabc\nabc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2280
        c'abc\nabc\nabc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2281
        c'abc\nabc\nabc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2282
        c'a\nb\nc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2283
        c'a\n\n\nb\nc\n\n\n\nd'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2284
    ) do:[:eachTestString |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2285
        |testString sColl calledWith1 calledWith2 count1 count2 countReturned|
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2286
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2287
        #( yourself asUnicode16String asUnicode32String ) do:[:conv |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2288
            testString := eachTestString perform:conv.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2289
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2290
            "/ try asStringCollection as reference
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2291
            sColl := testString asStringCollection.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2292
            count1 := 0.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2293
            calledWith1 := OrderedCollection new.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2294
            sColl do:[:each |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2295
                count1 := count1 + 1.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2296
                calledWith1 add:each.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2297
            ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2298
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2299
            "/ check asCollectionOfLinesDo: 
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2300
            count2 := 0.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2301
            calledWith2 := OrderedCollection new.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2302
            countReturned := testString asCollectionOfLinesDo:[:each |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2303
                count2 := count2 + 1.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2304
                calledWith2 add:each.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2305
            ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2306
            self assert:(count1 == count2).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2307
            self assert:(count2 == countReturned).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2308
            self assert:(calledWith1 = calledWith2).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2309
        ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2310
    ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2311
!
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  2312
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2313
test91_enumeratingWords
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2314
    
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2315
    |  |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2316
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2317
    #(
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2318
        0 c''
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2319
        1 c'abc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2320
        0 c'\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2321
        1 c'abc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2322
        0 c'\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2323
        1 c'abc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2324
        1 c'\n\nabc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2325
        1 c'\nabc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2326
        3 c'abc\nabc\nabc'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2327
        3 c'abc\nabc\nabc\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2328
        3 c'abc\nabc\nabc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2329
        3 c'a\nb\nc\n\n'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2330
        4 c'a\n\n\nb\nc\n\n\n\nd'
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2331
    ) pairWiseDo:[:expectedCount :eachTestString |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2332
        |testString sColl calledWith1 calledWith2 count1 count2 countReturned|
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  2333
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2334
        #( yourself asUnicode16String asUnicode32String ) do:[:conv |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2335
            testString := eachTestString perform:conv.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2336
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2337
            "/ try asStringCollection as reference
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2338
            sColl := testString asCollectionOfWords.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2339
            count1 := 0.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2340
            calledWith1 := OrderedCollection new.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2341
            sColl do:[:each |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2342
                count1 := count1 + 1.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2343
                calledWith1 add:each.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2344
            ].
1214
11cb005634cb class: RegressionTests::StringTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1103
diff changeset
  2345
2364
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2346
            "/ check asCollectionOfWordsDo: 
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2347
            count2 := 0.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2348
            calledWith2 := OrderedCollection new.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2349
            countReturned := testString asCollectionOfWordsDo:[:each |
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2350
                count2 := count2 + 1.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2351
                calledWith2 add:each.
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2352
            ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2353
            self assert:(count1 == expectedCount).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2354
            self assert:(count1 == count2).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2355
            self assert:(count2 == countReturned).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2356
            self assert:(calledWith1 = calledWith2).
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2357
        ].
41b2b20fa672 #QUALITY by exept
Claus Gittinger <cg@exept.de>
parents: 2328
diff changeset
  2358
    ].
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
! !
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
!StringTests class methodsFor:'documentation'!
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
version
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
    ^ '$Header$'
570
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  2365
!
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  2366
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  2367
version_CVS
705b823baac2 string error
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
  2368
    ^ '$Header$'
283
6aeeeda25c69 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
! !
752
ef9236c7271c class: RegressionTests::StringTests
Stefan Vogel <sv@exept.de>
parents: 751
diff changeset
  2370