Hi Ben, 

Although it was mentioned that I may not need to test this private
method, here is the image version: 40505. 

Thanks, 

Sheri 

what version of Pharo?
System > System Reporter > Image > Latest update ?
cheers -ben

On Fri, Mar 13, 2015 at 6:08 AM, <[email protected]> wrote:

> Hi all, I'm trying to test MultiByteFileStream>>next:innerFor: and I am 
> running into some perplexing results. Here is the test code I wrote, trying 
> to get a Character cr at the end of a String:

> testString := '? ? ?' , (Character cr) asString .

> filename := 'test-file-' , 99 atRandom printString , '.txt'. 
> MultiByteFileStream forceNewFileNamed: filename do: [ :stream | stream next: 
> 10 innerFor: testString. ].

> and the code for MultiByteFileStream>>next:innerFor:

> next: n innerFor: aString

> | peekChar state |

> "if we just read a CR, and the next character is an LF, then skip the LF" 
> aString size = 0 ifTrue: [^ aString].

> (aString last = Character cr)

> ifTrue:

> [ state := converter saveStateOf: self.

> peekChar := self bareNext.

> "super peek doesn't work because it relies on #next" (peekChar notNil and: 
> [peekChar ~= Character lf])

> ifTrue: [ converter restoreStateOf: self with: state. ].

> ]. ^ aString withSqueakLineEndings.

> I can't get the line: (aString last = Character cr) to return "True" so that 
> I can test the path into this part of the method. Would anyone be able to 
> explain how to do that, or maybe what approach to take to test this method? 
> Many thanks, Sheridan

 

Reply via email to