Skip to content

Commit

Permalink
Issue #79: #testUpToAll wasn't testing utf8 encoded streams, unlike #…
Browse files Browse the repository at this point in the history
…testUpToAllTwice, so added utf8 encoded streams to #testUpToAll (and boom) also updated #testUpToAll samples to include strings from #testUpToAllTwice ... failing tests
  • Loading branch information
dalehenrich committed Dec 10, 2022
1 parent 8cd2604 commit 762fd3f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Zinc-Character-Encoding-Tests/ZnCharacterStreamTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ ZnCharacterStreamTests >> assertUpTo: array [
{ #category : 'testing' }
ZnCharacterStreamTests >> assertUpToAll: array [
| encodingStream |
encodingStream := array first class == String
ifTrue: [ self eightBitReadStreamOn: array first ]
ifFalse: [ self utf8ReadStreamOn: array first ].
self assert: (array first readStream upToAll: array second) equals: array third.
self assert: (encodingStream upToAll: array second) equals: array third
encodingStream := self utf8ReadStreamOn: array first .
self assert: (encodingStream upToAll: array second) equals: array third.
encodingStream := self eightBitReadStreamOn: array first.
self assert: (encodingStream upToAll: array second) equals: array third.
]

{ #category : 'testing' }
Expand Down Expand Up @@ -213,6 +213,7 @@ ZnCharacterStreamTests >> testUpToAll [
('iße' 'ß' 'i')
('eißen' 'ße' 'ei')
('eißen' 'ßend' 'eißen')
('eißendeße' 'ße' 'ei')
('abcdefgh' 'cd' 'ab')
('a' '' '')
('a' 'a' '')
Expand All @@ -239,11 +240,15 @@ ZnCharacterStreamTests >> testUpToAllTwice [

string := 'eißendeße'.
stream := string readStreamPortable.
self assert: (stream upToAll: 'ße') equals: 'ei'.
self assert: (stream upToAll: 'ße') equals: 'nde'.

eightBitStream := self eightBitReadStreamOn: string.
utf8Stream := self utf8ReadStreamOn: string.

self assert: (stream upToAll: 'ße') equals: 'ei'.
self assert: (eightBitStream upToAll: 'ße') equals: 'ei'.
self assert: (utf8Stream upToAll: 'ße') equals: 'ei'.

self assert: (stream upToAll: 'ße') equals: 'nde'.
self assert: (eightBitStream upToAll: 'ße') equals: 'nde'.
self assert: (utf8Stream upToAll: 'ße') equals: 'nde'.

a := 'ABC', (Character codePoint: 128), (Character codePoint: 255).
Expand Down

0 comments on commit 762fd3f

Please sign in to comment.