#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Tue, 02 Apr 2019 11:11:34 +0200
changeset 2211 632cea1b911c
parent 2210 d3368bb7f119
child 2212 80b766225587
#QUALITY by cg class: RegressionTests::StringTests added: #test42a_includesAny #test42b_includesMatchCharacters #test42c_includesSeparator #test60a_hash #test60b_hash #test82a_expanding #test82b_expanding #test84_withCRs removed: #test42_includesAny #test60_hash #test82_expanding changed: #test50_indexOf
RegressionTests__StringTests.st
--- a/RegressionTests__StringTests.st	Tue Apr 02 10:52:09 2019 +0200
+++ b/RegressionTests__StringTests.st	Tue Apr 02 11:11:34 2019 +0200
@@ -749,23 +749,54 @@
     "
 !
 
-test42_includesAny
+test42a_includesAny
     |s|
 
     1 to:20 do:[:na |
-	s := (String new:na withAll:$a),'bla bla 1234'.
-	self assert:( s includesAny:'12').
-	self assert:( s includesAny:'21').
-	self assert:( s includesAny:'15').
-	self assert:( s includesAny:'51').
-	self assert:( s includesAny:'45').
-	self assert:( s includesAny:'54').
-	self assert:( s includesAny:'56') not.
+        s := (String new:na withAll:$a),'bla bla 1234'.
+        self assert:( s includesAny:'12').
+        self assert:( s includesAny:'21').
+        self assert:( s includesAny:'15').
+        self assert:( s includesAny:'51').
+        self assert:( s includesAny:'45').
+        self assert:( s includesAny:'54').
+        self assert:( s includesAny:'56') not.
     ].
 
     "
-     self new test42_includesAny
+     self new test42a_includesAny
+    "
+
+    "Created: / 02-04-2019 / 11:03:13 / Claus Gittinger"
+!
+
+test42b_includesMatchCharacters
+    self assert:('hello' includesMatchCharacters not).
+    self assert:('he*llo' includesMatchCharacters).
+    self assert:('h[eE]llo' includesMatchCharacters).
+    self assert:('h#llo' includesMatchCharacters).
+    
+    "
+     self new test42b_includesMatchCharacters
     "
+
+    "Created: / 02-04-2019 / 11:03:46 / Claus Gittinger"
+!
+
+test42c_includesSeparator
+    self assert:('hello' includesSeparator not).
+    self assert:('he llo' includesSeparator).
+    self assert:(' hello' includesSeparator).
+    self assert:('hello ' includesSeparator).
+    self assert:(' he llo ' includesSeparator).
+    self assert:(c'h\nllo' includesSeparator).
+    self assert:(c'h\tllo' includesSeparator).
+    
+    "
+     self new test42c_includesSeparator
+    "
+
+    "Created: / 02-04-2019 / 11:05:39 / Claus Gittinger"
 !
 
 test43_occurrencesOf
@@ -810,8 +841,8 @@
 
     s := 'Some Sample Generators (74035660-d1f6-11df-9ab3-00ff7b08316c)'.
     1 to:s size do:[:start |
-	i := s indexOf:$- startingAt:start.
-	self assert:(i == 0 or:[ i >= start]).
+        i := s indexOf:$- startingAt:start.
+        self assert:(i == 0 or:[ i >= start]).
     ].
     "/             12345678901
     self assert:( 'hello world' indexOf:$0 startingAt:1 ) == 0.
@@ -935,11 +966,26 @@
     self assert:(s indexOf:(Character space) startingAt:512) == 512.
     self assert:(s indexOf:(Character space) startingAt:513) == 0.
 
+    self assert:(s indexOfSeparator) == 512.
+    self assert:(s indexOfSeparatorStartingAt:1) == 512.
+    self assert:(s indexOfSeparatorStartingAt:2) == 512.
+    self assert:(s indexOfSeparatorStartingAt:3) == 512.
+    self assert:(s indexOfSeparatorStartingAt:4) == 512.
+    self assert:(s indexOfSeparatorStartingAt:5) == 512.
+    self assert:(s indexOfSeparatorStartingAt:6) == 512.
+    self assert:(s indexOfSeparatorStartingAt:7) == 512.
+    self assert:(s indexOfSeparatorStartingAt:8) == 512.
+    self assert:(s indexOfSeparatorStartingAt:9) == 512.
+    self assert:(s indexOfSeparatorStartingAt:511) == 512.
+    self assert:(s indexOfSeparatorStartingAt:512) == 512.
+    self assert:(s indexOfSeparatorStartingAt:513) == 0.
+
     "
      self new test50_indexOf
     "
 
     "Created: / 29-10-2010 / 14:58:21 / cg"
+    "Modified: / 02-04-2019 / 11:06:52 / Claus Gittinger"
 !
 
 test51_substrings
@@ -1100,7 +1146,7 @@
     "
 !
 
-test60_hash
+test60a_hash
     "
     As of 2013-01-09 for strings of size 7 String & Unicode16String hash
     returned different values. This test checks this
@@ -1109,21 +1155,25 @@
     | tester |
 
     tester := [:s|
-	|sHash u16Hash u32Hash|
+        |sHash u16Hash u32Hash|
 
-	sHash := s hash.
-	u16Hash := s asUnicode16String hash.
-	u32Hash := s asUnicode32String hash.
+        sHash := s hash.
+        u16Hash := s asUnicode16String hash.
+        u32Hash := s asUnicode32String hash.
 
-	self assert: sHash == u16Hash
-	     description: ('String and Unicode16String hashes differ on "%1" (%2)'
-				bindWith:s with:s class name).
-	self assert: sHash == u32Hash
-	     description: ('String and Unicode32String hashes differ on "%1" (%2)'
-				bindWith:s with:s class name)
+        self assert: sHash == u16Hash
+             description: ('String and Unicode16String hashes differ on "%1" (%2)'
+                                bindWith:s with:s class name).
+        self assert: sHash == u32Hash
+             description: ('String and Unicode32String hashes differ on "%1" (%2)'
+                                bindWith:s with:s class name)
     ].
 
     tester value:'a'.
+    tester value:'123456789012345678'.
+    tester value:'12345678901234567'.
+    tester value:'1234567890123456'.
+    tester value:'123456789012345'.
     tester value:'12345678901234'.
     tester value:'1234567890123'.
     tester value:'123456789012'.
@@ -1150,6 +1200,14 @@
     tester value:('1234567' copyWith:Character null).
     tester value:('12345678' copyWith:Character null).
     tester value:('123456789' copyWith:Character null).
+    tester value:('1234567890' copyWith:Character null).
+    tester value:('12345678901' copyWith:Character null).
+    tester value:('123456789012' copyWith:Character null).
+    tester value:('1234567890123' copyWith:Character null).
+    tester value:('12345678901234' copyWith:Character null).
+    tester value:('123456789012345' copyWith:Character null).
+    tester value:('1234567890123456' copyWith:Character null).
+    tester value:('12345678901234567' copyWith:Character null).
 
     tester value:('' copyWith:Character null),'123'.
     tester value:('1' copyWith:Character null),'123'.
@@ -1161,11 +1219,41 @@
     tester value:('1234567' copyWith:Character null),'123'.
     tester value:('12345678' copyWith:Character null),'123'.
     tester value:('123456789' copyWith:Character null),'123'.
+    tester value:('1234567890' copyWith:Character null),'123'.
+    tester value:('12345678901' copyWith:Character null),'123'.
+    tester value:('123456789012' copyWith:Character null),'123'.
+    tester value:('1234567890123' copyWith:Character null),'123'.
+    tester value:('12345678901234' copyWith:Character null),'123'.
+    tester value:('123456789012345' copyWith:Character null),'123'.
+    tester value:('1234567890123456' copyWith:Character null),'123'.
+
+    "Created: / 02-04-2019 / 10:55:23 / Claus Gittinger"
+!
+
+test60b_hash
+    | tester |
+
+    self skip:'takes long'.
+    
+    tester := [:s|
+        |sHash u16Hash u32Hash|
+
+        sHash := s hash.
+        u16Hash := s asUnicode16String hash.
+        u32Hash := s asUnicode32String hash.
+
+        self assert: sHash == u16Hash
+             description: ('String and Unicode16String hashes differ on "%1" (%2)'
+                                bindWith:s with:s class name).
+        self assert: sHash == u32Hash
+             description: ('String and Unicode32String hashes differ on "%1" (%2)'
+                                bindWith:s with:s class name)
+    ].
 
     "/ String allInstancesDo:[:each| tester value:each].
     Symbol allInstancesDo:[:each| tester value:each].
 
-    "Created: / 09-01-2013 / 10:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 02-04-2019 / 10:55:26 / Claus Gittinger"
 !
 
 test65_concatenation
@@ -1441,7 +1529,7 @@
     self assert: str = 'FFF'.
 !
 
-test82_expanding
+test82a_expanding
 
     | rslt |
 
@@ -1483,7 +1571,21 @@
             ].
     self assert:(rslt = 'A10,B20,C').
 
-    "Created: / 14-01-2019 / 18:35:40 / Claus Gittinger"
+    "Created: / 02-04-2019 / 11:00:08 / Claus Gittinger"
+!
+
+test82b_expanding
+    | rslt |
+
+    rslt := 'hello' copyExpanding:(Dictionary 
+                                        withKeys:{$h . $e . $o} 
+                                        andValues:{'HH' . 'EE' . $O }).
+    self assert:(rslt = 'HHEEllO').
+
+    rslt := 'he%2llo%1' % { 123 . 456 }.
+    self assert:(rslt = 'he456llo123').
+
+    "Created: / 02-04-2019 / 11:00:43 / Claus Gittinger"
 !
 
 test83_padding
@@ -1544,6 +1646,15 @@
     "Created: / 21-03-2019 / 12:58:33 / Claus Gittinger"
 !
 
+test84_withCRs
+    | rslt |
+
+    rslt := 'foo\bar' addLineDelimiters.
+    self assert:(rslt = ('foo',Character cr,'bar')).
+
+    "Created: / 02-04-2019 / 10:57:44 / Claus Gittinger"
+!
+
 test90_hash
     "all string-representations must hash equal"