Levente Uzonyi uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-ul.250.mcz ==================== Summary ==================== Name: CollectionsTests-ul.250 Author: ul Time: 9 September 2015, 8:33:02.788 pm UUID: eab1e808-8b9c-4d1e-beaa-d6476b070026 Ancestors: CollectionsTests-ul.249 ByteArrayTest>>verifyPlatformIndepentendIntegerAccessorsMatch:for:setter:getter:storageBits:bigEndian: checks all possible index ranges of the given ByteArray. =============== Diff against CollectionsTests-ul.249 =============== Item was changed: ----- Method: ByteArrayTest>>verifyPlatformIndepentendIntegerAccessorsAtBitBordersSetter:getter:unsigned:storageBits: (in category 'testing - platform independent access') ----- verifyPlatformIndepentendIntegerAccessorsAtBitBordersSetter: setter getter: getter unsigned: unsigned storageBits: storageBits | byteArray minValue maxValue baseValues | + byteArray := ByteArray new: storageBits // 8 * 2. - byteArray := ByteArray new: storageBits // 8. unsigned ifTrue: [ minValue := 0. maxValue := 1 << storageBits - 1. baseValues := #(0 1) ] ifFalse: [ minValue := -1 << (storageBits - 1). maxValue := 1 << (storageBits - 1) - 1. baseValues := #(-1 0 1) ]. #(true false) do: [ :bigEndian | 0 to: storageBits - 1 do: [ :bits | baseValues do: [ :baseValue | | centerValue | centerValue := baseValue << bits. centerValue - 1 to: centerValue + 1 do: [ :value | (value between: minValue and: maxValue) ifTrue: [ self verifyPlatformIndepentendIntegerAccessorsMatch: byteArray for: value setter: setter getter: getter storageBits: storageBits bigEndian: bigEndian ] ] ] ] ] ! Item was changed: ----- Method: ByteArrayTest>>verifyPlatformIndepentendIntegerAccessorsMatch:for:setter:getter:storageBits:bigEndian: (in category 'testing - platform independent access') ----- verifyPlatformIndepentendIntegerAccessorsMatch: byteArray for: value setter: setter getter: getter storageBits: storageBits bigEndian: bigEndian + | expectedSetterResult getterResult bytes | - | expectedSetterResult getterResult | expectedSetterResult := self byteArrayFor: value bits: storageBits bigEndian: bigEndian. + bytes := storageBits // 8. + 1 to: byteArray size - bytes + 1 do: [ :index | + byteArray + perform: setter + with: index + with: value + with: bigEndian. + 1 to: bytes do: [ :byteIndex | + self + assert: (expectedSetterResult at: byteIndex) + equals: (byteArray at: index + byteIndex - 1) ]. + getterResult := byteArray + perform: getter + with: index + with: bigEndian. + self assert: value equals: getterResult ]! - byteArray perform: setter with: 1 with: value with: bigEndian. - self assert: expectedSetterResult equals: byteArray. - getterResult := byteArray perform: getter with: 1 with: bigEndian. - self assert: value equals: getterResult! Item was changed: ----- Method: ByteArrayTest>>verifyPlatformIndepentendIntegerAccessorsWithRandomValuesSetter:getter:unsigned:storageBits:random: (in category 'testing - platform independent access') ----- verifyPlatformIndepentendIntegerAccessorsWithRandomValuesSetter: setter getter: getter unsigned: unsigned storageBits: storageBits random: random | byteArray randomMax randomOffset | + byteArray := ByteArray new: storageBits // 8 * 2. - byteArray := ByteArray new: storageBits // 8. randomMax := 1 << storageBits. randomOffset := unsigned ifTrue: [ -1 ] ifFalse: [ -1 << (storageBits - 1) - 1 ]. 10000 timesRepeat: [ | value | value := (random nextInt: randomMax) + randomOffset. #(true false) do: [ :bigEndian | self verifyPlatformIndepentendIntegerAccessorsMatch: byteArray for: value setter: setter getter: getter storageBits: storageBits bigEndian: bigEndian ] ]! |
Free forum by Nabble | Edit this page |