#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Sun, 08 May 2016 02:22:20 +0200
changeset 1421 3236b9c7d993
parent 1420 d5438e5960ed
child 1422 8e237a64a6f2
#QUALITY by cg class: RegressionTests::StringTests added: #test43_occurrencesOf changed: #test42_includesAny
RegressionTests__StringTests.st
--- a/RegressionTests__StringTests.st	Sun May 08 02:17:40 2016 +0200
+++ b/RegressionTests__StringTests.st	Sun May 08 02:22:20 2016 +0200
@@ -3,10 +3,10 @@
 "{ NameSpace: RegressionTests }"
 
 TestCase subclass:#StringTests
-        instanceVariableNames:''
-        classVariableNames:''
-        poolDictionaries:''
-        category:'tests-Regression-Collections'
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-Regression-Collections'
 !
 
 
@@ -134,17 +134,17 @@
 
 test01_access
     0 to:33 do:[:l |
-        |str|
+	|str|
 
-        str := String new:l.
-        str atAllPut:(Character space).
-        self assert:( str isBlank ).
+	str := String new:l.
+	str atAllPut:(Character space).
+	self assert:( str isBlank ).
 
-        1 to:l do:[:pos |
-            str at:pos put:$a.
-            self assert:( str isBlank not ).
-            str at:pos put:(Character space).
-        ].
+	1 to:l do:[:pos |
+	    str at:pos put:$a.
+	    self assert:( str isBlank not ).
+	    str at:pos put:(Character space).
+	].
     ].
     self runAccessTestsOnInstancesOf:String
 
@@ -157,13 +157,13 @@
     |myStringClass s1|
 
     Class withoutUpdatingChangesDo:[
-        myStringClass := String
-                        subclass:#'MyString'
-                        instanceVariableNames:'foo'
-                        classVariableNames:''
-                        poolDictionaries:nil.
-        myStringClass compile:'foo ^foo'.
-        myStringClass compile:'foo:arg foo := arg'.
+	myStringClass := String
+			subclass:#'MyString'
+			instanceVariableNames:'foo'
+			classVariableNames:''
+			poolDictionaries:nil.
+	myStringClass compile:'foo ^foo'.
+	myStringClass compile:'foo:arg foo := arg'.
     ].
 
     s1 := (myStringClass new:5) replaceFrom:1 with:'hello'.
@@ -187,17 +187,17 @@
 
 test10_Contains8BitCharacters
     0 to:65 do:[:l |
-        |str|
+	|str|
 
-        str := String new:l.
-        str atAllPut:(Character value:16r7F).
-        self assert:( str contains8BitCharacters not ).
+	str := String new:l.
+	str atAllPut:(Character value:16r7F).
+	self assert:( str contains8BitCharacters not ).
 
-        1 to:l do:[:pos |
-            str at:pos put:(Character value:16r80).
-            self assert:( str contains8BitCharacters ).
-            str at:pos put:(Character value:16r7F).
-        ].
+	1 to:l do:[:pos |
+	    str at:pos put:(Character value:16r80).
+	    self assert:( str contains8BitCharacters ).
+	    str at:pos put:(Character value:16r7F).
+	].
     ].
 
     "
@@ -213,19 +213,19 @@
     parserFlags arraysAreImmutable:true.
 
     Class withoutUpdatingChangesDo:[
-        myClass := Object
-                        subclass:#'MyClass'
-                        instanceVariableNames:''
-                        classVariableNames:''
-                        poolDictionaries:nil.
+	myClass := Object
+			subclass:#'MyClass'
+			instanceVariableNames:''
+			classVariableNames:''
+			poolDictionaries:nil.
 
-        compiler := myClass compilerClass new.
-        compiler parserFlags:parserFlags.
-        compiler compile:'lit1 ^''hello''' forClass:myClass install:true.
+	compiler := myClass compilerClass new.
+	compiler parserFlags:parserFlags.
+	compiler compile:'lit1 ^''hello''' forClass:myClass install:true.
 
-        compiler := myClass compilerClass new.
-        compiler parserFlags:parserFlags.
-        compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true.
+	compiler := myClass compilerClass new.
+	compiler parserFlags:parserFlags.
+	compiler compile:'lit2 ^#(''foo'' ''bar'' ''baz'')' forClass:myClass install:true.
     ].
 
     s1 := myClass new perform:#lit1.
@@ -249,6 +249,37 @@
     "Modified: / 02-08-2011 / 19:30:53 / cg"
 !
 
+test30_indexOf
+    |i|
+      "/  12345678901
+    i := 'hello world' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
+    self assert:(i == 7).
+    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:true.
+    self assert:(i == 0).
+    i := 'hello wOrLd' indexOfSubCollection:'world' startingAt:1 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 7).
+    i := 'hello wOrLd' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 3).
+
+    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:1 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 3).
+    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:3 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 3).
+    i := 'hello wOrLd yellow' indexOfSubCollection:'ll' startingAt:4 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 15).
+
+    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:1 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 16).
+    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:17 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 0).
+    i := 'hello wOrLd yellow' indexOfSubCollection:'low' startingAt:18 ifAbsent:0 caseSensitive:false.
+    self assert:(i == 0).
+
+    "
+     self new test30_indexOf
+    "
+!
+
 test30_indexOfSubCollection
     |i|
       "/  12345678901
@@ -339,8 +370,9 @@
     "
      self new test42_includesAny
     "
+!
 
-test42_occurrencesOf
+test43_occurrencesOf
     |s|
 
     "/             12345678901
@@ -371,12 +403,10 @@
     1 to:1024 by:2 do:[:i | s at:i put:$b].
     self assert:(s occurrencesOf:$a) == 512.
     self assert:(s occurrencesOf:$b) == 512.
-    
+
     "
-     self new test42_occurrencesOf
+     self new test43_occurrencesOf
     "
-
-    "Created: / 29-10-2010 / 14:58:21 / cg"
 !
 
 test50_indexOf
@@ -750,12 +780,12 @@
     self assert: str = 'FFF'.
 
     self should:[
-        str from:-1 to:-1 put:$x
+	str from:-1 to:-1 put:$x
     ] raise:SubscriptOutOfBoundsError.
     self assert: str = 'FFF'.
 
     self should:[
-        str from:-1 to:1 put:$x
+	str from:-1 to:1 put:$x
     ] raise:SubscriptOutOfBoundsError.
     self assert: str = 'FFF'.
 !