Skip to content

Commit

Permalink
Cleanup Arrayed collections tests
Browse files Browse the repository at this point in the history
  • Loading branch information
astares committed Sep 16, 2019
1 parent 7a1e8ca commit 5d8780e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
19 changes: 11 additions & 8 deletions src/Collections-Tests/ByteArrayTest.class.st
Expand Up @@ -66,14 +66,17 @@ ByteArrayTest >> testFourthByteArraysReturnTheCorrectValues [
]

{ #category : #tests }
ByteArrayTest >> testHex [

self assert: #[122 43 213 7] hex = '7a2bd507'.
self assert: #[151 193 242 221 249 32 153 72 179 41 49 154 48 193 99 134] hex = '97c1f2ddf9209948b329319a30c16386'.

self assert: (ByteArray readHexFrom: '7A2BD507') = #[122 43 213 7].
self assert: (ByteArray readHexFrom: '7a2bd507') = #[122 43 213 7].

ByteArrayTest >> testHex [
self assert: #[122 43 213 7] hex equals: '7a2bd507'.
self
assert: #[151 193 242 221 249 32 153 72 179 41 49 154 48 193 99 134] hex
equals: '97c1f2ddf9209948b329319a30c16386'.
self
assert: (ByteArray readHexFrom: '7A2BD507')
equals: #[122 43 213 7].
self
assert: (ByteArray readHexFrom: '7a2bd507')
equals: #[122 43 213 7]
]

{ #category : #tests }
Expand Down
8 changes: 4 additions & 4 deletions src/Collections-Tests/IntegerArrayTest.class.st
Expand Up @@ -11,10 +11,10 @@ Class {
IntegerArrayTest >> testAt [
| array |
array := IntegerArray new: 5 withAll: 2.
self assert: (array at: 3) = 2.
self assert: (array at: 3) equals: 2.

array at: 3 put: 5.
self assert: (array at: 3) = 5
self assert: (array at: 3) equals: 5

]

Expand All @@ -23,13 +23,13 @@ IntegerArrayTest >> testPutAllNegative [
| array |
array := IntegerArray new: 2.
array atAllPut: -1000.
self assert: (array at: 2) = -1000
self assert: (array at: 2) equals: -1000
]

{ #category : #tests }
IntegerArrayTest >> testPutNegative [
| array |
array := IntegerArray new: 2.
array at: 2 put: -1000.
self assert: (array at: 2) = -1000
self assert: (array at: 2) equals: -1000
]
10 changes: 5 additions & 5 deletions src/Collections-Tests/NativeArrayTest.class.st
Expand Up @@ -51,16 +51,16 @@ NativeArrayTest >> testAtAllPut [
self guineaPigHerd do: [ :guineaPig |
guineaPig atAllPut: 42.
1 to: (self wordSize min: guineaPig size) do: [ :i |
self assert: (guineaPig at: i) = 42 ].
self assert: (guineaPig at: i) equals: 42 ].
(guineaPig size - self wordSize max: 1) to: guineaPig size do: [ :i |
self assert: (guineaPig at: i) = 42 ] ]
self assert: (guineaPig at: i) equals: 42 ] ]
]

{ #category : #tests }
NativeArrayTest >> testAtAllPutFail [
"Makes sure the primitive works correctly with different data structures"
self guineaPigHerd do: [ :guineaPig |
self should: [guineaPig atAllPut: -1] raise: Error ].
self should: [guineaPig atAllPut: -1] raise: Error ]
]

{ #category : #tests }
Expand Down Expand Up @@ -100,8 +100,8 @@ NativeArrayTest >> testReplaceFromToWithStartingAt [
1 to: copy size do: [ :l | copy at: l put: l ].
self alignmentIndexesDo: [ :i :j :k |
guineaPig replaceFrom: i to: j + 8 with: copy startingAt: k.
self assert: (guineaPig at: i) = (copy at: k).
self assert: (guineaPig at: j + 8) = (copy at: j + 8 - i + k) ] ]
self assert: (guineaPig at: i) equals: (copy at: k).
self assert: (guineaPig at: j + 8) equals: (copy at: j + 8 - i + k) ] ]
]

{ #category : #utilities }
Expand Down

0 comments on commit 5d8780e

Please sign in to comment.