Nicolas Cellier uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-nice.4.mcz ==================== Summary ==================== Name: MultilingualTests-nice.4 Author: nice Time: 22 December 2009, 12:21:37 pm UUID: 2fd29bf7-ae88-4462-923a-121e7d695028 Ancestors: MultilingualTests-nice.3 Add a few tests for MultiByteFileStream. Includes an expected failure for backChunk. =============== Diff against MultilingualTests-nice.3 =============== Item was added: + ----- Method: MultiByteFileStreamTest>>testNextLine (in category 'testing') ----- + testNextLine + + | foo fileName | + + fileName := 'foolinend.txt'. + + foo := MultiByteFileStream forceNewFileNamed: fileName. + [foo wantsLineEndConversion: false. + foo nextPutAll: 'line 1'; cr; nextPutAll: 'line 2'; nextPutAll: String crlf; nextPutAll: 'line 3'; nextPut: Character lf; nextPutAll: 'line 4'] ensure: [foo close]. + + #(cr lf crlf nil) do: [:lineEnding | + foo := MultiByteFileStream oldFileNamed: fileName. + [foo lineEndConvention: lineEnding. + self assert: (foo nextLine) = ('line 1'). + self assert: (foo nextLine) = ('line 2'). + self assert: (foo nextLine) = ('line 3'). + self assert: (foo nextLine) = ('line 4'). + self assert: (foo nextLine) = nil] ensure: [foo close]]. + + FileDirectory default deleteFileNamed: fileName! Item was added: + ----- Method: MultiByteFileStreamTest>>testNonAsciiBackChunk (in category 'testing') ----- + testNonAsciiBackChunk + "Note: this is an expected failure: MultiByteFileStream is not equipped to read back non ASCII String... (no comment) + As a consequence, never use non ASCII in method category nor in your initials. That would make a few tools blind..." + + | foo fileName | + + fileName := 'foobackchunk.txt'. + + foo := MultiByteFileStream forceNewFileNamed: fileName. + [foo lineEndConvention: #cr; converter: UTF8TextConverter new. + foo cr; nextChunkPut: 'testé' printString. + foo cr; nextChunkPut: 'test' printString. + self assert: foo backChunk = (String cr , 'test' printString). + self assert: foo backChunk = (String cr , 'testé' printString).] ensure: [foo close]. + + FileDirectory default deleteFileNamed: fileName! Item was added: + ----- Method: MultiByteFileStreamTest>>expectedFailures (in category 'testing') ----- + expectedFailures + ^#(#testNonAsciiBackChunk)! Item was added: + ----- Method: MultiByteFileStreamTest>>testLineEnding (in category 'testing') ----- + testLineEnding + + | foo fileName | + + fileName := 'foolinend.txt'. + + foo := MultiByteFileStream forceNewFileNamed: fileName. + [foo wantsLineEndConversion: false. + foo nextPutAll: 'line 1'; cr; nextPutAll: 'line 2'; nextPutAll: String crlf; nextPutAll: 'line 3'; nextPut: Character lf; nextPutAll: 'line 4'] ensure: [foo close]. + + { + {#cr. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}. + {#lf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}. + {#crlf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}. + {nil. 'line 1' , String cr , 'line 2' , String crlf , 'line 3' , String lf , 'line 4'} + } do: [:lineEndingResult | + foo := MultiByteFileStream oldFileNamed: fileName. + [foo lineEndConvention: lineEndingResult first. + self assert: (foo upToEnd) = lineEndingResult last] ensure: [foo close]]. + + FileDirectory default deleteFileNamed: fileName! Item was added: + ----- Method: MultiByteFileStreamTest>>testAsciiBackChunk (in category 'testing') ----- + testAsciiBackChunk + + | foo fileName | + + fileName := 'foobackchunk.txt'. + + foo := MultiByteFileStream forceNewFileNamed: fileName. + [foo lineEndConvention: #cr; converter: UTF8TextConverter new. + foo cr; nextChunkPut: 'test1' printString. + foo cr; nextChunkPut: 'test2' printString. + self assert: foo backChunk = (String cr , 'test2' printString). + self assert: foo backChunk = (String cr , 'test1' printString).] ensure: [foo close]. + + FileDirectory default deleteFileNamed: fileName! |
Free forum by Nabble | Edit this page |