/
ShortIntegerArrayTest.class.st
73 lines (54 loc) · 1.77 KB
/
ShortIntegerArrayTest.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"
SUnit Test for ShortIntegerArray
"
Class {
#name : #ShortIntegerArrayTest,
#superclass : #TestCase,
#instVars : [
'shortIntegerArray'
],
#category : #'Balloon-Tests-Collections'
}
{ #category : #running }
ShortIntegerArrayTest >> setUp [
super setUp.
shortIntegerArray := ShortIntegerArray with: 4 with: 4+256 with: 2 with: 1+(256*10).
]
{ #category : #tests }
ShortIntegerArrayTest >> testAt [
self assert: 2 equals: (shortIntegerArray at: 3)
]
{ #category : #tests }
ShortIntegerArrayTest >> testAtPut [
shortIntegerArray at: 3 put: 100.
self assert: 100 equals: (shortIntegerArray at: 3)
]
{ #category : #tests }
ShortIntegerArrayTest >> testSetUp [
self assert: 4 equals: (shortIntegerArray at:1) .
self assert: 4+256 equals: (shortIntegerArray at:2).
self assert: 2 equals: (shortIntegerArray at:3).
self assert: 1+(256*10) equals: (shortIntegerArray at:4).
]
{ #category : #tests }
ShortIntegerArrayTest >> testSwapBytePairs [
shortIntegerArray swapBytePairsHacky.
self assert: 4*256 equals: (shortIntegerArray at:1).
self assert: 4*256 + 1 equals: (shortIntegerArray at:2).
self assert: 2*256 equals: (shortIntegerArray at:3).
self assert: 1*256 + 10 equals: (shortIntegerArray at:4).
]
{ #category : #tests }
ShortIntegerArrayTest >> testWriteBigEndianOn [
|stream|
stream := WriteStream on: Array new.
shortIntegerArray write: (12 bitShift: 24) + (34 bitShift: 16) + (56 bitShift: 8) + 78 bigEndianOn: stream.
self assert: #(12 34 56 78) equals: stream contents
]
{ #category : #tests }
ShortIntegerArrayTest >> testWriteLittleEndianOn [
|stream|
stream := WriteStream on: Array new.
shortIntegerArray write: (12 bitShift: 24) + (34 bitShift: 16) + (56 bitShift: 8) + 78 littleEndianOn: stream.
self assert: #(56 78 12 34) equals: stream contents
]