The Trunk: CollectionsTests-topa.265.mcz

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

The Trunk: CollectionsTests-topa.265.mcz

commits-2
Tobias Pape uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-topa.265.mcz

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

Name: CollectionsTests-topa.265
Author: topa
Time: 10 July 2016, 8:59:28.460057 pm
UUID: ab27728f-2668-44b0-9857-33016d691ee4
Ancestors: CollectionsTests-ul.264

Add a test for Ascii85 conversion

=============== Diff against CollectionsTests-ul.264 ===============

Item was added:
+ TestCase subclass: #Ascii85ConverterTest
+ instanceVariableNames: 'decoded encoded'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'CollectionsTests-Streams'!
+
+ !Ascii85ConverterTest commentStamp: '<historical>' prior: 0!
+ This is the unit test for the class Base64MimeConverter. Unit tests are a good way to exercise the functionality of your system in a repeatable and automatic manner. They are therefore recommended if you plan to release anything. For more information, see:
+ - http://www.c2.com/cgi/wiki?UnitTest
+ - http://minnow.cc.gatech.edu/squeak/1547
+ - the sunit class category!

Item was added:
+ ----- Method: Ascii85ConverterTest>>decoded (in category 'accessing') -----
+ decoded
+
+ ^ decoded!

Item was added:
+ ----- Method: Ascii85ConverterTest>>decoded: (in category 'accessing') -----
+ decoded: anObject
+
+ decoded := anObject!

Item was added:
+ ----- Method: Ascii85ConverterTest>>encoded (in category 'accessing') -----
+ encoded
+
+ ^ encoded!

Item was added:
+ ----- Method: Ascii85ConverterTest>>encoded: (in category 'accessing') -----
+ encoded: anObject
+
+ encoded := anObject!

Item was added:
+ ----- Method: Ascii85ConverterTest>>hackedEncoded (in category 'accessing') -----
+ hackedEncoded
+
+ ^ String streamContents:
+ [:out | | in |
+ in := self encoded readStream.
+ out
+ nextPutAll: (in next: 5);
+ cr;
+ nextPutAll: (in next: 4);
+ space;
+ nextPutAll: in upToEnd]
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>setUp (in category 'initialize-release') -----
+ setUp
+ self decoded: 'Hi There!!'.
+ self encoded: '<~8802GBOu3q+T~>'.!

Item was added:
+ ----- Method: Ascii85ConverterTest>>testAscii85Encoded (in category 'tests') -----
+ testAscii85Encoded
+
+ self
+ assert: (Ascii85Converter encode: self decoded) contents
+ equals: self decoded ascii85Encoded
+ description: 'The convenience method should match the converters output'
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecode1Zero (in category 'tests') -----
+ testDecode1Zero
+ | bits chars |
+ bits := #[0].
+ chars := '<~!!!!~>'.
+ self
+ assert: bits
+ equals: (Ascii85Converter decodeToBytes: chars) contents
+ description: 'Decoding should decode three zeros without squashing'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecode3Zeros (in category 'tests') -----
+ testDecode3Zeros
+ | bits chars |
+ bits := #[0 0 0].
+ chars := '<~!!!!!!!!~>'.
+ self
+ assert: bits
+ equals: (Ascii85Converter decodeToBytes: chars) contents
+ description: 'Decoding should decode three zeros without squashing'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecode4Zeros (in category 'tests') -----
+ testDecode4Zeros
+ | bits chars |
+ bits := #[0 0 0 0].
+ chars := '<~z~>'.
+ self
+ assert: bits
+ equals: (Ascii85Converter decodeToBytes: chars) contents
+ description: 'Decoding should decode four zeros with squashing'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecode5Zeros (in category 'tests') -----
+ testDecode5Zeros
+ | bits chars |
+ bits := #[0 0 0 0 0].
+ chars := '<~z!!!!~>'.
+ self
+ assert: bits
+ equals: (Ascii85Converter decodeToBytes: chars) contents
+ description: 'Decoding should decode five zeros with squashing and a bang'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecodeEndTooShort (in category 'tests') -----
+ testDecodeEndTooShort
+ | chars |
+ chars := '<~z!!~>'.
+ self
+ should: [Ascii85Converter decodeToBytes: chars]
+ raise: Error
+ description: 'Decoding too short end tuple should raise an error'.!

Item was added:
+ ----- Method: Ascii85ConverterTest>>testDecodeIgnoreFiller (in category 'tests') -----
+ testDecodeIgnoreFiller
+
+ self
+ assert: self decoded
+ equals: self hackedEncoded ascii85Decoded
+ description: 'Decoding should ignore linebreaks and spaces'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testEncodeDecode (in category 'tests') -----
+ testEncodeDecode
+
+ | encoded |
+ encoded := (Ascii85Converter encode: self decoded) contents.
+ self
+ assert: self encoded
+ equals: encoded
+ description: 'A simple text should be encodable.'.
+ self
+ assert: self decoded
+ equals: (Ascii85Converter decodeToChars: encoded) contents
+ description: 'The encoded text decoded should match the original'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testEncodeDecodeMultiLine (in category 'tests') -----
+ testEncodeDecodeMultiLine
+ " PLRM page 131:
+ It inserts a newline in the encoded output at least once every 80 characters,
+ thereby limiting the lengths of lines.
+ "
+ | aHundred encodedLines |
+ aHundred := String new: 100 withAll: $a.
+ encodedLines := (Ascii85Converter encode: aHundred) contents lines.
+ self
+ assert: (encodedLines collect: [:ea | ea size]) max <= 80
+ description: 'Encoded long lines should break at max 80 characters'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testEncodeDecodeWithZ (in category 'tests') -----
+ testEncodeDecodeWithZ
+ " PLRM page 131:
+ As a special case, if all five digits are 0, they are represented by a single character z
+ instead of by !!!!!!!!!!.
+ "
+ | bits chars |
+ bits := #[40 50 60 0 0 0 0 0 0 0 0 0 0 0 40 50 60].
+ chars := '<~-o*mbzz!!!!"E&49~>'.
+ self
+ assert: chars
+ equals: (Ascii85Converter encode: bits) contents
+ description: 'Encoding should squash five-tuples of 0 to z'.
+ self
+ assert: chars
+ equals: (Ascii85Converter encode: bits asString) contents
+ description: 'Encoding should squash five-tuples of 0 to z'.
+ self
+ assert: bits
+ equals: (Ascii85Converter decodeToBytes: chars) contents
+ description: 'Decoding should unsquash z to five-tuples of 0'.
+ self
+ assert: bits asString
+ equals: (Ascii85Converter decodeToChars: chars) contents
+ description: 'Decoding should unsquash z to five-tuples of 0'.
+ !

Item was added:
+ ----- Method: Ascii85ConverterTest>>testOnByteArray (in category 'tests') -----
+ testOnByteArray
+
+ self assert: self encoded equals: self decoded asByteArray ascii85Encoded.!