The Trunk: MultilingualTests-ul.23.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: MultilingualTests-ul.23.mcz

commits-2
Levente Uzonyi uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-ul.23.mcz

==================== Summary ====================

Name: MultilingualTests-ul.23
Author: ul
Time: 23 April 2017, 8:17:33.823601 pm
UUID: 4d4598b1-98ec-4129-9887-169a2c449ebb
Ancestors: MultilingualTests-ul.22

- improved the error messages, added some comments, and simplified a bit MultiByteFileStreamTest >> #testByteTextConverter

=============== Diff against MultilingualTests-ul.22 ===============

Item was changed:
  ----- Method: MultiByteFileStreamTest>>testByteTextConverter (in category 'testing') -----
  testByteTextConverter
+
+ | byteCharacters |
+ byteCharacters := Character allByteCharacters.
+ ByteTextConverter allSubclassesDo: [ :converterClass |
+ | converter stream encoded decoded encoded2 |
+ converter := converterClass new.
+ stream := byteCharacters readStream.
+ "Find bytes that can be decoded by this converter."
+ encoded := byteCharacters select: [ :e | (converter nextFromStream: stream) notNil ].
+ "Decode those bytes."
+ stream := encoded readStream.
+ decoded := encoded collect: [ :e | converter nextFromStream: stream ].
+ self assert: stream atEnd.
+ "Re-encode the decoded bytes using #nextPutAll:toStream:, and check if they match the original bytes."
+ encoded2 := String streamContents: [ :writeStream |
+ converter nextPutAll: decoded toStream: writeStream ].
+ encoded with: encoded2 do: [ :original :reencoded |
+ self
+ assert: original charCode = reencoded charCode
+ description: [ '{1} could not decode or re-encode {2} using #nextPutAll:toStream:. Instead, it yielded {3}.'
+ format: {
+ converterClass name.
+ original charCode.
+ reencoded charCode } ] ].
+ "Re-encode the decoded bytes using #nextPut:toStream:, and check if they match the original bytes."
+ encoded2 := String streamContents: [ :writeStream |
+ decoded do: [:e | converter nextPut: e toStream: writeStream ] ].
+ encoded with: encoded2 do: [ :original :reencoded |
+ self
+ assert: original charCode = reencoded charCode
+ description: [ '{1} could not decode or re-encode {2} using #nextPut:toStream:. Instead, it yielded {3}.'
+ format: {
+ converterClass name.
+ original charCode.
+ reencoded charCode } ] ] ]!
- | strings converterClasses |
- strings := {
- String newFrom: ((0 to: 255) collect: [:e | e asCharacter]).
- }.
-
- converterClasses := ByteTextConverter allSubclasses.
- converterClasses do: [:converterClass |
- strings do: [:string | | converter stream encoded decoded encoded2 |
- converter := converterClass new.
- stream := string readStream.
- encoded := string select: [:e | (converter nextFromStream: stream) notNil].
- stream := encoded readStream.
- decoded := encoded collect: [:e | converter nextFromStream: stream].
- self assert: stream atEnd.
- stream := String new writeStream.
- converter nextPutAll: decoded toStream: stream.
- encoded2 := stream contents.
- self assert: (encoded2 collect: [:e | e charCode] as: Array) = (encoded collect: [:e | e charCode] as: Array).
- stream := String new writeStream.
- decoded do: [:e | converter nextPut: e toStream: stream].
- encoded2 := stream contents.
- self assert: (encoded2 collect: [:e | e charCode] as: Array) = (encoded collect: [:e | e charCode] as: Array)]]!