1357
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1113
|
3 |
"{ Package: 'exept:regression' }"
|
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#UninterpretedBytesTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression-Collections'
|
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!UninterpretedBytesTest methodsFor:'tests'!
|
|
16 |
|
1357
|
17 |
test00_byteAccess
|
|
18 |
|bytes|
|
|
19 |
|
|
20 |
bytes := #[ 16r10 16r20 16r30 16r40 ].
|
|
21 |
|
|
22 |
self assert:(bytes byteAt:1) == 16r10.
|
|
23 |
self assert:(bytes byteAt:2) == 16r20.
|
|
24 |
self assert:(bytes byteAt:3) == 16r30.
|
|
25 |
self assert:(bytes byteAt:4) == 16r40.
|
|
26 |
|
|
27 |
self assert:(bytes signedByteAt:1) == 16r10.
|
|
28 |
self assert:(bytes signedByteAt:2) == 16r20.
|
|
29 |
self assert:(bytes signedByteAt:3) == 16r30.
|
|
30 |
self assert:(bytes signedByteAt:4) == 16r40.
|
|
31 |
|
|
32 |
bytes := #[ 16rFF 16r7F 16r80 16r81 ].
|
|
33 |
|
|
34 |
self assert:(bytes byteAt:1) == 16rFF.
|
|
35 |
self assert:(bytes byteAt:2) == 16r7F.
|
|
36 |
self assert:(bytes byteAt:3) == 16r80.
|
|
37 |
self assert:(bytes byteAt:4) == 16r81.
|
|
38 |
|
|
39 |
self assert:(bytes signedByteAt:1) == -1.
|
|
40 |
self assert:(bytes signedByteAt:2) == 127.
|
|
41 |
self assert:(bytes signedByteAt:3) == -128.
|
|
42 |
self assert:(bytes signedByteAt:4) == -127.
|
|
43 |
|
|
44 |
bytes := bytes copy.
|
|
45 |
|
|
46 |
bytes byteAt:1 put:16r10.
|
|
47 |
self assert:(bytes byteAt:1) == 16r10.
|
|
48 |
self assert:(bytes signedByteAt:1) == 16r10.
|
|
49 |
|
|
50 |
bytes byteAt:1 put:16r80.
|
|
51 |
self assert:(bytes byteAt:1) == 16r80.
|
|
52 |
self assert:(bytes signedByteAt:1) == -128.
|
|
53 |
|
|
54 |
bytes signedByteAt:1 put:16r10.
|
|
55 |
self assert:(bytes byteAt:1) == 16r10.
|
|
56 |
self assert:(bytes signedByteAt:1) == 16r10.
|
|
57 |
|
|
58 |
bytes signedByteAt:1 put:-1.
|
|
59 |
self assert:(bytes byteAt:1) == 16rFF.
|
|
60 |
self assert:(bytes signedByteAt:1) == -1.
|
|
61 |
|
|
62 |
"
|
|
63 |
self run:#test00_byteAccess
|
|
64 |
"
|
|
65 |
!
|
|
66 |
|
|
67 |
test01_int16Access
|
|
68 |
|bytes|
|
|
69 |
|
|
70 |
bytes := #[ 16r10 16r20 16r30 16r40 ].
|
|
71 |
|
|
72 |
self assert:(bytes unsignedInt16At:1 MSB:true) = 16r1020.
|
|
73 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r2010.
|
|
74 |
self assert:(bytes unsignedInt16At:2 MSB:true) = 16r2030.
|
|
75 |
self assert:(bytes unsignedInt16At:2 MSB:false) = 16r3020.
|
|
76 |
self assert:(bytes unsignedInt16At:3 MSB:true) = 16r3040.
|
|
77 |
self assert:(bytes unsignedInt16At:3 MSB:false) = 16r4030.
|
|
78 |
|
|
79 |
self assert:(bytes signedInt16At:1 MSB:true) = 16r1020.
|
|
80 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r2010.
|
|
81 |
self assert:(bytes signedInt16At:2 MSB:true) = 16r2030.
|
|
82 |
self assert:(bytes signedInt16At:2 MSB:false) = 16r3020.
|
|
83 |
self assert:(bytes signedInt16At:3 MSB:true) = 16r3040.
|
|
84 |
self assert:(bytes signedInt16At:3 MSB:false) = 16r4030.
|
|
85 |
|
|
86 |
|
|
87 |
bytes := #[ 16rFF 16r7F 16r80 16r81 ].
|
|
88 |
|
|
89 |
self assert:(bytes unsignedInt16At:1 MSB:true) = 16rFF7F.
|
|
90 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r7FFF.
|
|
91 |
self assert:(bytes unsignedInt16At:2 MSB:true) = 16r7F80.
|
|
92 |
self assert:(bytes unsignedInt16At:2 MSB:false) = 16r807F.
|
|
93 |
self assert:(bytes unsignedInt16At:3 MSB:true) = 16r8081.
|
|
94 |
self assert:(bytes unsignedInt16At:3 MSB:false) = 16r8180.
|
|
95 |
|
|
96 |
self assert:(bytes signedInt16At:1 MSB:true) = -129. "/ 16rFF7F signExtendedShortValue
|
|
97 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r7FFF.
|
|
98 |
self assert:(bytes signedInt16At:2 MSB:true) = 16r7F80.
|
|
99 |
self assert:(bytes signedInt16At:2 MSB:false) = -32641. "/ 16r807F signExtendedShortValue.
|
|
100 |
self assert:(bytes signedInt16At:3 MSB:true) = -32639. "/ 16r8081 signExtendedShortValue.
|
|
101 |
self assert:(bytes signedInt16At:3 MSB:false) = -32384. "/ 16r8180 signExtendedShortValue.
|
|
102 |
|
|
103 |
bytes := bytes copy.
|
|
104 |
|
|
105 |
bytes unsignedInt16At:1 put:16r1020 MSB:false.
|
|
106 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r1020.
|
|
107 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r1020.
|
|
108 |
|
|
109 |
bytes unsignedInt16At:1 put:16r1020 MSB:true.
|
|
110 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r2010.
|
|
111 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r2010.
|
|
112 |
|
|
113 |
bytes unsignedInt16At:1 put:16rFFFE MSB:false.
|
|
114 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16rFFFE.
|
|
115 |
self assert:(bytes signedInt16At:1 MSB:false) = -2.
|
|
116 |
|
|
117 |
bytes unsignedInt16At:1 put:16rFFFE MSB:true.
|
|
118 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16rFEFF.
|
|
119 |
self assert:(bytes signedInt16At:1 MSB:false) = -257. "/ 16rFEFF signExtendedShortValue
|
|
120 |
|
|
121 |
bytes signedInt16At:1 put:16r1020 MSB:false.
|
|
122 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r1020.
|
|
123 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r1020.
|
|
124 |
|
|
125 |
bytes signedInt16At:1 put:16r1020 MSB:true.
|
|
126 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16r2010.
|
|
127 |
self assert:(bytes signedInt16At:1 MSB:false) = 16r2010.
|
|
128 |
|
|
129 |
bytes signedInt16At:1 put:-3 MSB:false.
|
|
130 |
self assert:(bytes unsignedInt16At:1 MSB:false) = 16rFFFD.
|
|
131 |
self assert:(bytes signedInt16At:1 MSB:false) = -3.
|
|
132 |
|
|
133 |
"
|
|
134 |
self run:#test01_int16Access
|
|
135 |
"
|
|
136 |
!
|
|
137 |
|
|
138 |
test02_int32Access
|
|
139 |
|bytes|
|
|
140 |
|
|
141 |
bytes := #[ 16r10 16r20 16r30 16r40 16r50 ].
|
|
142 |
|
|
143 |
self assert:(bytes unsignedInt32At:1 MSB:true) = 16r10203040.
|
|
144 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r40302010.
|
|
145 |
self assert:(bytes unsignedInt32At:2 MSB:true) = 16r20304050.
|
|
146 |
self assert:(bytes unsignedInt32At:2 MSB:false) = 16r50403020.
|
|
147 |
|
|
148 |
self assert:(bytes signedInt32At:1 MSB:true) = 16r10203040.
|
|
149 |
self assert:(bytes signedInt32At:1 MSB:false) = 16r40302010.
|
|
150 |
self assert:(bytes signedInt32At:2 MSB:true) = 16r20304050.
|
|
151 |
self assert:(bytes signedInt32At:2 MSB:false) = 16r50403020.
|
|
152 |
|
|
153 |
|
|
154 |
bytes := #[ 16r80 16rFF 16r01 16r03 16r80 ].
|
|
155 |
|
|
156 |
self assert:(bytes unsignedInt32At:1 MSB:true) = 16r80FF0103.
|
|
157 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r0301FF80.
|
|
158 |
self assert:(bytes unsignedInt32At:2 MSB:true) = 16rFF010380.
|
|
159 |
self assert:(bytes unsignedInt32At:2 MSB:false) = 16r800301FF.
|
|
160 |
|
|
161 |
self assert:(bytes signedInt32At:1 MSB:true) = -2130771709. "/ 16r80FF0103 signExtendedLongValue
|
|
162 |
self assert:(bytes signedInt32At:1 MSB:false) = 16r0301FF80.
|
|
163 |
self assert:(bytes signedInt32At:2 MSB:true) = -16710784. "/ 16rFF010380 signExtendedLongValue.
|
|
164 |
self assert:(bytes signedInt32At:2 MSB:false) = -2147286529. "/ 16r800301FF signExtendedLongValue.
|
|
165 |
|
|
166 |
bytes := bytes copy.
|
|
167 |
|
|
168 |
bytes unsignedInt32At:1 put:16r10203040 MSB:false.
|
|
169 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r10203040.
|
|
170 |
self assert:(bytes signedInt32At:1 MSB:false) = 16r10203040.
|
|
171 |
|
|
172 |
bytes unsignedInt32At:1 put:16r10203040 MSB:true.
|
|
173 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r40302010.
|
|
174 |
self assert:(bytes signedInt32At:1 MSB:false) = 16r40302010.
|
|
175 |
|
|
176 |
bytes unsignedInt32At:1 put:16r10203080 MSB:true.
|
|
177 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r80302010.
|
|
178 |
self assert:(bytes signedInt32At:1 MSB:false) = -2144329712. "/ 16r80302010 signExtendedLongValue.
|
|
179 |
|
|
180 |
bytes unsignedInt32At:1 put:16rFFFFFFFE MSB:false.
|
|
181 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16rFFFFFFFE.
|
|
182 |
self assert:(bytes signedInt32At:1 MSB:false) = -2.
|
|
183 |
|
|
184 |
bytes signedInt32At:1 put:16r40302010 MSB:false.
|
|
185 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16r40302010.
|
|
186 |
self assert:(bytes signedInt32At:1 MSB:false) = 16r40302010.
|
|
187 |
|
|
188 |
bytes signedInt32At:1 put:-3 MSB:false.
|
|
189 |
self assert:(bytes unsignedInt32At:1 MSB:false) = 16rFFFFFFFD.
|
|
190 |
self assert:(bytes signedInt32At:1 MSB:false) = -3.
|
|
191 |
|
|
192 |
"
|
|
193 |
self run:#test02_int32Access
|
|
194 |
"
|
|
195 |
!
|
|
196 |
|
|
197 |
test03_int64Access
|
|
198 |
|bytes|
|
|
199 |
|
|
200 |
bytes := #[ 16r10 16r20 16r30 16r40 16r50 16r60 16r70 16r80 16r90].
|
|
201 |
|
|
202 |
self assert:(bytes unsignedInt64At:1 MSB:true) = 16r1020304050607080.
|
|
203 |
self assert:(bytes unsignedInt64At:1 MSB:false) = 16r8070605040302010.
|
|
204 |
self assert:(bytes unsignedInt64At:2 MSB:true) = 16r2030405060708090.
|
|
205 |
self assert:(bytes unsignedInt64At:2 MSB:false) = 16r9080706050403020.
|
|
206 |
|
|
207 |
self assert:(bytes signedInt64At:1 MSB:true) = 16r1020304050607080.
|
|
208 |
self assert:(bytes signedInt64At:1 MSB:false) = -9191740941672636400. "/ 16r8070605040302010 signExtendedLongLongValue
|
|
209 |
self assert:(bytes signedInt64At:2 MSB:true) = 16r2030405060708090.
|
|
210 |
self assert:(bytes signedInt64At:2 MSB:false) = -8034298176263409632. "/ 16r9080706050403020 signExtendedLongLongValue.
|
|
211 |
|
|
212 |
bytes := bytes copy.
|
|
213 |
bytes unsignedInt64At:1 put:16r30405060708090A0 MSB:true.
|
|
214 |
self assert:(bytes unsignedInt64At:1 MSB:true) = 16r30405060708090A0.
|
|
215 |
self assert:(bytes unsignedInt64At:1 MSB:false) = 16rA090807060504030.
|
|
216 |
self assert:(bytes signedInt64At:1 MSB:true) = 16r30405060708090A0.
|
|
217 |
self assert:(bytes signedInt64At:1 MSB:false) = -6876855410854182864. "/ 16rA090807060504030 signExtendedLongLongValue.
|
|
218 |
|
|
219 |
bytes signedInt64At:1 put:-6876855410854182864 MSB:true.
|
|
220 |
self assert:(bytes unsignedInt64At:1 MSB:true) = 16rA090807060504030.
|
|
221 |
self assert:(bytes signedInt64At:1 MSB:true) = -6876855410854182864.
|
|
222 |
|
|
223 |
bytes signedInt64At:1 put:-6876855410854182864 MSB:false.
|
|
224 |
self assert:(bytes unsignedInt64At:1 MSB:false) = 16rA090807060504030.
|
|
225 |
self assert:(bytes signedInt64At:1 MSB:false) = -6876855410854182864.
|
|
226 |
|
|
227 |
bytes unsignedInt64At:1 put:16r30405060708090A0 MSB:false.
|
|
228 |
self assert:(bytes unsignedInt64At:1 MSB:true) = 16rA090807060504030.
|
|
229 |
self assert:(bytes unsignedInt64At:1 MSB:false) = 16r30405060708090A0.
|
|
230 |
self assert:(bytes signedInt64At:1 MSB:true) = -6876855410854182864. "/ 16rA090807060504030 signExtendedLongLongValue.
|
|
231 |
self assert:(bytes signedInt64At:1 MSB:false) = 16r30405060708090A0.
|
|
232 |
|
|
233 |
"
|
|
234 |
self run:#test03_int64Access
|
|
235 |
"
|
|
236 |
!
|
|
237 |
|
|
238 |
test10_floatAccess
|
1113
|
239 |
|bytes|
|
|
240 |
|
|
241 |
bytes := ByteArray new:4.
|
|
242 |
bytes floatAt:1 put:1.234.
|
|
243 |
self assert:(bytes = #[182 243 157 63]).
|
|
244 |
|
|
245 |
bytes floatAt:1 put:2.345 asShortFloat.
|
|
246 |
self assert:(bytes = #[123 20 22 64]).
|
|
247 |
|
|
248 |
bytes floatAt:1 put:345.
|
|
249 |
self assert:(bytes = #[0 128 172 67]).
|
|
250 |
|
|
251 |
|
|
252 |
bytes := ByteArray new:8.
|
|
253 |
bytes doubleAt:1 put:1.234.
|
|
254 |
self assert:(bytes = #[88 57 180 200 118 190 243 63]).
|
|
255 |
|
|
256 |
bytes doubleAt:1 put:2.345 asShortFloat.
|
|
257 |
self assert:(bytes = #[0 0 0 96 143 194 2 64]).
|
|
258 |
|
|
259 |
bytes doubleAt:1 put:345.
|
|
260 |
self assert:(bytes = #[0 0 0 0 0 144 117 64]).
|
|
261 |
|
|
262 |
"
|
1357
|
263 |
self run:#test10_floatAccess
|
1113
|
264 |
"
|
|
265 |
! !
|
|
266 |
|
|
267 |
!UninterpretedBytesTest class methodsFor:'documentation'!
|
|
268 |
|
|
269 |
version
|
|
270 |
^ '$Header$'
|
|
271 |
!
|
|
272 |
|
|
273 |
version_CVS
|
|
274 |
^ '$Header$'
|
|
275 |
! !
|
|
276 |
|