|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <liboil/liboil.h> |
|
20 #include <liboil/liboilfunction.h> |
|
21 #include <stdio.h> |
|
22 #include <stdlib.h> |
|
23 |
|
24 #include <liboil/globals.h> |
|
25 |
|
26 #define LOG_FILE "c:\\logs\\testsuite_convert_log.txt" |
|
27 #include "std_log_result.h" |
|
28 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
29 |
|
30 #define SIZE 20 |
|
31 |
|
32 void create_xml(int result) |
|
33 { |
|
34 if(result) |
|
35 assert_failed = 1; |
|
36 |
|
37 testResultXml("testsuite_convert"); |
|
38 close_log_file(); |
|
39 } |
|
40 |
|
41 #define SIGN_BIT_8 0x80 |
|
42 #define SIGN_BIT_16 0x8000 |
|
43 #define SIGN_BIT_32 0x80000000 |
|
44 |
|
45 #define MAX_SIGNED_INT_32 0x7FFFFFFF |
|
46 #define MAX_SIGNED_INT_16 0x7FFF |
|
47 #define MAX_SIGNED_INT_16 0x7FFF |
|
48 #define MAX_SIGNED_INT_8 0x7F |
|
49 |
|
50 #define MAX_UNSIGNED_INT16 0xFFFF |
|
51 #define MAX_UNSIGNED_INT8 0xFF |
|
52 |
|
53 float f32src[] = {0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0, 11.1, 12.2, 13.3, 14.4, 15.5, 16.6, 17.7, 18.8, 19.9}; |
|
54 double f64src[] = {0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.0, 11.1, 12.2, 13.3, 14.4, 15.5, 16.6, 17.7, 18.8, 19.9}; |
|
55 |
|
56 void test_oil_convert_s16_f32() |
|
57 { |
|
58 int16_t output[SIZE]; |
|
59 int i = 0; |
|
60 |
|
61 oil_convert_s16_f32(output, f32src, SIZE); |
|
62 |
|
63 for(i = 0; i<SIZE; i++) |
|
64 { |
|
65 if(output[i] != i) |
|
66 { |
|
67 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
68 assert_failed = 1; |
|
69 } |
|
70 } |
|
71 } |
|
72 |
|
73 void test_oil_convert_s16_f64() |
|
74 { |
|
75 int16_t output[SIZE]; |
|
76 int i = 0; |
|
77 |
|
78 oil_convert_s16_f64(output, f64src, SIZE); |
|
79 |
|
80 for(i = 0; i<SIZE; i++) |
|
81 { |
|
82 if(output[i] != i) |
|
83 { |
|
84 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
85 assert_failed = 1; |
|
86 } |
|
87 } |
|
88 } |
|
89 |
|
90 void test_oil_convert_s16_s32() |
|
91 { |
|
92 int32_t input[SIZE]; |
|
93 int16_t output[SIZE]; |
|
94 int i = 0; |
|
95 |
|
96 for(i=0; i<SIZE; i++) |
|
97 input[i] = i; |
|
98 |
|
99 oil_convert_s16_s32(output, input, SIZE); |
|
100 |
|
101 for(i = 0; i<SIZE; i++) |
|
102 { |
|
103 if(output[i] != i) |
|
104 { |
|
105 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
106 assert_failed = 1; |
|
107 } |
|
108 } |
|
109 } |
|
110 |
|
111 void test_oil_convert_s16_s8() |
|
112 { |
|
113 int8_t input[SIZE]; |
|
114 int16_t output[SIZE]; |
|
115 int i = 0; |
|
116 |
|
117 for(i=0; i<SIZE; i++) |
|
118 input[i] = i; |
|
119 |
|
120 oil_convert_s16_s8(output, input, SIZE); |
|
121 |
|
122 for(i = 0; i<SIZE; i++) |
|
123 { |
|
124 if(output[i] != i) |
|
125 { |
|
126 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
127 assert_failed = 1; |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 void test_oil_convert_s16_u16() |
|
133 { |
|
134 uint16_t input[SIZE]; |
|
135 int16_t output[SIZE]; |
|
136 int i = 0; |
|
137 |
|
138 for(i=0; i<SIZE; i++) |
|
139 { |
|
140 if(i < SIZE/2) |
|
141 input[i] = i; |
|
142 else |
|
143 input[i] = i | SIGN_BIT_16; |
|
144 } |
|
145 |
|
146 oil_convert_s16_u16(output, input, SIZE); |
|
147 |
|
148 for(i = 0; i<SIZE; i++) |
|
149 { |
|
150 if(i < SIZE/2) |
|
151 { |
|
152 if(output[i] != i) |
|
153 { |
|
154 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
155 assert_failed = 1; |
|
156 } |
|
157 } |
|
158 else |
|
159 { |
|
160 if(output[i] != MAX_SIGNED_INT_16) |
|
161 { |
|
162 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_16,output[i]); |
|
163 assert_failed = 1; |
|
164 } |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 void test_oil_convert_s16_u32() |
|
170 { |
|
171 uint32_t input[SIZE]; |
|
172 int16_t output[SIZE]; |
|
173 int i = 0; |
|
174 |
|
175 for(i=0; i<SIZE; i++) |
|
176 { |
|
177 if(i < SIZE/2) |
|
178 input[i] = i; |
|
179 else |
|
180 input[i] = i | SIGN_BIT_32; |
|
181 } |
|
182 |
|
183 oil_convert_s16_u32(output, input, SIZE); |
|
184 |
|
185 for(i = 0; i<SIZE; i++) |
|
186 { |
|
187 if(i < SIZE/2) |
|
188 { |
|
189 if(output[i] != i) |
|
190 { |
|
191 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
192 assert_failed = 1; |
|
193 } |
|
194 } |
|
195 else |
|
196 { |
|
197 if(output[i] != MAX_SIGNED_INT_16) |
|
198 { |
|
199 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_16,output[i]); |
|
200 assert_failed = 1; |
|
201 } |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 void test_oil_convert_s16_u8() |
|
207 { |
|
208 uint8_t input[SIZE]; |
|
209 int16_t output[SIZE]; |
|
210 int i = 0; |
|
211 |
|
212 for(i=0; i<SIZE; i++) |
|
213 { |
|
214 if(i < SIZE/2) |
|
215 input[i] = i; |
|
216 else |
|
217 input[i] = i | SIGN_BIT_8; |
|
218 } |
|
219 |
|
220 oil_convert_s16_u8(output, input, SIZE); |
|
221 |
|
222 for(i = 0; i<SIZE; i++) |
|
223 { |
|
224 if(output[i] != input[i]) |
|
225 { |
|
226 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
227 assert_failed = 1; |
|
228 } |
|
229 } |
|
230 } |
|
231 |
|
232 void test_oil_convert_s32_f64() |
|
233 { |
|
234 double input[SIZE]; |
|
235 int32_t output[SIZE]; |
|
236 int i = 0; |
|
237 |
|
238 for(i=0; i<SIZE; i++) |
|
239 input[i] = i; |
|
240 |
|
241 oil_convert_s32_f64(output, input, SIZE); |
|
242 |
|
243 for(i = 0; i<SIZE; i++) |
|
244 { |
|
245 if(output[i] != i) |
|
246 { |
|
247 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
248 assert_failed = 1; |
|
249 } |
|
250 } |
|
251 } |
|
252 |
|
253 void test_oil_convert_s32_s16() |
|
254 { |
|
255 int16_t input[SIZE]; |
|
256 int32_t output[SIZE]; |
|
257 int i = 0; |
|
258 |
|
259 for(i=0; i<SIZE; i++) |
|
260 input[i] = i; |
|
261 |
|
262 oil_convert_s32_s16(output, input, SIZE); |
|
263 |
|
264 for(i = 0; i<SIZE; i++) |
|
265 { |
|
266 if(output[i] != i) |
|
267 { |
|
268 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
269 assert_failed = 1; |
|
270 } |
|
271 } |
|
272 } |
|
273 |
|
274 void test_oil_convert_s32_s8() |
|
275 { |
|
276 int8_t input[SIZE]; |
|
277 int32_t output[SIZE]; |
|
278 int i = 0; |
|
279 |
|
280 for(i=0; i<SIZE; i++) |
|
281 input[i] = i; |
|
282 |
|
283 oil_convert_s32_s8(output, input, SIZE); |
|
284 |
|
285 for(i = 0; i<SIZE; i++) |
|
286 { |
|
287 if(output[i] != i) |
|
288 { |
|
289 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
290 assert_failed = 1; |
|
291 } |
|
292 } |
|
293 } |
|
294 |
|
295 void test_oil_convert_s32_u16() |
|
296 { |
|
297 uint16_t input[SIZE]; |
|
298 int32_t output[SIZE]; |
|
299 int i = 0; |
|
300 |
|
301 for(i=0; i<SIZE; i++) |
|
302 { |
|
303 if(i < SIZE/2) |
|
304 input[i] = i; |
|
305 else |
|
306 input[i] = i | SIGN_BIT_16; |
|
307 } |
|
308 |
|
309 oil_convert_s32_u16(output, input, SIZE); |
|
310 |
|
311 for(i = 0; i<SIZE; i++) |
|
312 { |
|
313 if(i < SIZE/2) |
|
314 { |
|
315 if(output[i] != i) |
|
316 { |
|
317 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
318 assert_failed = 1; |
|
319 } |
|
320 } |
|
321 else |
|
322 { |
|
323 if(output[i] != input[i]) |
|
324 { |
|
325 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
326 assert_failed = 1; |
|
327 } |
|
328 } |
|
329 } |
|
330 } |
|
331 |
|
332 void test_oil_convert_s32_u32() |
|
333 { |
|
334 uint32_t input[SIZE]; |
|
335 int32_t output[SIZE]; |
|
336 int i = 0; |
|
337 |
|
338 for(i=0; i<SIZE; i++) |
|
339 { |
|
340 if(i < SIZE/2) |
|
341 input[i] = i; |
|
342 else |
|
343 input[i] = i | SIGN_BIT_32; |
|
344 } |
|
345 |
|
346 oil_convert_s32_u32(output, input, SIZE); |
|
347 |
|
348 for(i = 0; i<SIZE; i++) |
|
349 { |
|
350 if(i < SIZE/2) |
|
351 { |
|
352 if(output[i] != i) |
|
353 { |
|
354 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
355 assert_failed = 1; |
|
356 } |
|
357 } |
|
358 else |
|
359 { |
|
360 if(output[i] != MAX_SIGNED_INT_32) |
|
361 { |
|
362 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_32,output[i]); |
|
363 assert_failed = 1; |
|
364 } |
|
365 } |
|
366 } |
|
367 } |
|
368 |
|
369 void test_oil_convert_s32_u8() |
|
370 { |
|
371 uint8_t input[SIZE]; |
|
372 int32_t output[SIZE]; |
|
373 int i = 0; |
|
374 |
|
375 for(i=0; i<SIZE; i++) |
|
376 { |
|
377 if(i < SIZE/2) |
|
378 input[i] = i; |
|
379 else |
|
380 input[i] = i | SIGN_BIT_8; |
|
381 } |
|
382 |
|
383 oil_convert_s32_u8(output, input, SIZE); |
|
384 |
|
385 for(i = 0; i<SIZE; i++) |
|
386 { |
|
387 if(output[i] != input[i]) |
|
388 { |
|
389 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
390 assert_failed = 1; |
|
391 } |
|
392 } |
|
393 } |
|
394 |
|
395 void test_oil_convert_s8_f32() |
|
396 { |
|
397 int8_t output[SIZE]; |
|
398 int i = 0; |
|
399 |
|
400 oil_convert_s8_f32(output, f32src, SIZE); |
|
401 |
|
402 for(i = 0; i<SIZE; i++) |
|
403 { |
|
404 if(output[i] != i) |
|
405 { |
|
406 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
407 assert_failed = 1; |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 void test_oil_convert_s8_f64() |
|
413 { |
|
414 int8_t output[SIZE]; |
|
415 int i = 0; |
|
416 |
|
417 oil_convert_s8_f64(output, f64src, SIZE); |
|
418 |
|
419 for(i = 0; i<SIZE; i++) |
|
420 { |
|
421 if(output[i] != i) |
|
422 { |
|
423 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
424 assert_failed = 1; |
|
425 } |
|
426 } |
|
427 } |
|
428 |
|
429 void test_oil_convert_s8_s16() |
|
430 { |
|
431 int16_t input[SIZE]; |
|
432 int8_t output[SIZE]; |
|
433 int i = 0; |
|
434 |
|
435 for(i=0; i<SIZE; i++) |
|
436 { |
|
437 if(i < SIZE/2) |
|
438 input[i] = i; |
|
439 else |
|
440 input[i] = i | 0x100; |
|
441 } |
|
442 |
|
443 oil_convert_s8_s16(output, input, SIZE); |
|
444 |
|
445 for(i = 0; i<SIZE; i++) |
|
446 { |
|
447 if(i < SIZE/2) |
|
448 { |
|
449 if(output[i] != i) |
|
450 { |
|
451 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
452 assert_failed = 1; |
|
453 } |
|
454 } |
|
455 else |
|
456 { |
|
457 if(output[i] != MAX_SIGNED_INT_8) |
|
458 { |
|
459 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_8,output[i]); |
|
460 assert_failed = 1; |
|
461 } |
|
462 } |
|
463 } |
|
464 } |
|
465 |
|
466 void test_oil_convert_s8_s32() |
|
467 { |
|
468 int32_t input[SIZE]; |
|
469 int8_t output[SIZE]; |
|
470 int i = 0; |
|
471 |
|
472 for(i=0; i<SIZE; i++) |
|
473 { |
|
474 if(i < SIZE/2) |
|
475 input[i] = i; |
|
476 else |
|
477 input[i] = i | 0x10000; |
|
478 } |
|
479 |
|
480 oil_convert_s8_s32(output, input, SIZE); |
|
481 |
|
482 for(i = 0; i<SIZE; i++) |
|
483 { |
|
484 if(i < SIZE/2) |
|
485 { |
|
486 if(output[i] != i) |
|
487 { |
|
488 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
489 assert_failed = 1; |
|
490 } |
|
491 } |
|
492 else |
|
493 { |
|
494 if(output[i] != MAX_SIGNED_INT_8) |
|
495 { |
|
496 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_8,output[i]); |
|
497 assert_failed = 1; |
|
498 } |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 void test_oil_convert_s8_u16() |
|
504 { |
|
505 uint16_t input[SIZE]; |
|
506 int8_t output[SIZE]; |
|
507 int i = 0; |
|
508 |
|
509 for(i=0; i<SIZE; i++) |
|
510 { |
|
511 if(i < SIZE/2) |
|
512 input[i] = i; |
|
513 else |
|
514 input[i] = i | SIGN_BIT_16; |
|
515 } |
|
516 |
|
517 oil_convert_s8_u16(output, input, SIZE); |
|
518 |
|
519 for(i = 0; i<SIZE; i++) |
|
520 { |
|
521 if(i < SIZE/2) |
|
522 { |
|
523 if(output[i] != i) |
|
524 { |
|
525 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
526 assert_failed = 1; |
|
527 } |
|
528 } |
|
529 else |
|
530 { |
|
531 if(output[i] != MAX_SIGNED_INT_8) |
|
532 { |
|
533 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_8,output[i]); |
|
534 assert_failed = 1; |
|
535 } |
|
536 } |
|
537 } |
|
538 } |
|
539 |
|
540 void test_oil_convert_s8_u32() |
|
541 { |
|
542 uint32_t input[SIZE]; |
|
543 int8_t output[SIZE]; |
|
544 int i = 0; |
|
545 |
|
546 for(i=0; i<SIZE; i++) |
|
547 { |
|
548 if(i < SIZE/2) |
|
549 input[i] = i; |
|
550 else |
|
551 input[i] = i | SIGN_BIT_32; |
|
552 } |
|
553 |
|
554 oil_convert_s8_u32(output, input, SIZE); |
|
555 |
|
556 for(i = 0; i<SIZE; i++) |
|
557 { |
|
558 if(i < SIZE/2) |
|
559 { |
|
560 if(output[i] != i) |
|
561 { |
|
562 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
563 assert_failed = 1; |
|
564 } |
|
565 } |
|
566 else |
|
567 { |
|
568 if(output[i] != MAX_SIGNED_INT_8) |
|
569 { |
|
570 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_8,output[i]); |
|
571 assert_failed = 1; |
|
572 } |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 void test_oil_convert_s8_u8() |
|
578 { |
|
579 uint8_t input[SIZE]; |
|
580 int8_t output[SIZE]; |
|
581 int i = 0; |
|
582 |
|
583 for(i=0; i<SIZE; i++) |
|
584 { |
|
585 if(i < SIZE/2) |
|
586 input[i] = i; |
|
587 else |
|
588 input[i] = i | SIGN_BIT_8; |
|
589 } |
|
590 |
|
591 oil_convert_s8_u8(output, input, SIZE); |
|
592 |
|
593 for(i = 0; i<SIZE; i++) |
|
594 { |
|
595 if(i < SIZE/2) |
|
596 { |
|
597 if(output[i] != i) |
|
598 { |
|
599 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
600 assert_failed = 1; |
|
601 } |
|
602 } |
|
603 else |
|
604 { |
|
605 if(output[i] != MAX_SIGNED_INT_8) |
|
606 { |
|
607 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_SIGNED_INT_8,output[i]); |
|
608 assert_failed = 1; |
|
609 } |
|
610 } |
|
611 } |
|
612 } |
|
613 |
|
614 void test_oil_convert_u16_f32() |
|
615 { |
|
616 uint16_t output[SIZE]; |
|
617 int i = 0; |
|
618 |
|
619 oil_convert_u16_f32(output, f32src, SIZE); |
|
620 |
|
621 for(i = 0; i<SIZE; i++) |
|
622 { |
|
623 if(output[i] != i) |
|
624 { |
|
625 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
626 assert_failed = 1; |
|
627 } |
|
628 } |
|
629 } |
|
630 |
|
631 void test_oil_convert_u16_f64() |
|
632 { |
|
633 uint16_t output[SIZE]; |
|
634 int i = 0; |
|
635 |
|
636 oil_convert_u16_f64(output, f64src, SIZE); |
|
637 |
|
638 for(i = 0; i<SIZE; i++) |
|
639 { |
|
640 if(output[i] != i) |
|
641 { |
|
642 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
643 assert_failed = 1; |
|
644 } |
|
645 } |
|
646 } |
|
647 |
|
648 void test_oil_convert_u16_s16() |
|
649 { |
|
650 int16_t input[SIZE]; |
|
651 uint16_t output[SIZE]; |
|
652 int i = 0; |
|
653 |
|
654 for(i=0; i<SIZE; i++) |
|
655 { |
|
656 if(i < SIZE/2) |
|
657 input[i] = i; |
|
658 else |
|
659 input[i] = i | 0x100; |
|
660 } |
|
661 |
|
662 oil_convert_u16_s16(output, input, SIZE); |
|
663 |
|
664 for(i = 0; i<SIZE; i++) |
|
665 { |
|
666 if(output[i] != input[i]) |
|
667 { |
|
668 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
669 assert_failed = 1; |
|
670 } |
|
671 } |
|
672 } |
|
673 |
|
674 void test_oil_convert_u16_s32() |
|
675 { |
|
676 int32_t input[SIZE]; |
|
677 uint16_t output[SIZE]; |
|
678 int i = 0; |
|
679 |
|
680 for(i=0; i<SIZE; i++) |
|
681 { |
|
682 if(i < SIZE/2) |
|
683 input[i] = i; |
|
684 else |
|
685 input[i] = i | 0x10000; |
|
686 } |
|
687 |
|
688 oil_convert_u16_s32(output, input, SIZE); |
|
689 |
|
690 for(i = 0; i<SIZE; i++) |
|
691 { |
|
692 if(i < SIZE/2) |
|
693 { |
|
694 if(output[i] != i) |
|
695 { |
|
696 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
697 assert_failed = 1; |
|
698 } |
|
699 } |
|
700 else |
|
701 { |
|
702 if(output[i] != MAX_UNSIGNED_INT16) |
|
703 { |
|
704 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT16,output[i]); |
|
705 assert_failed = 1; |
|
706 } |
|
707 } |
|
708 } |
|
709 } |
|
710 |
|
711 void test_oil_convert_u16_u32() |
|
712 { |
|
713 uint32_t input[SIZE]; |
|
714 uint16_t output[SIZE]; |
|
715 int i = 0; |
|
716 |
|
717 for(i=0; i<SIZE; i++) |
|
718 { |
|
719 if(i < SIZE/2) |
|
720 input[i] = i; |
|
721 else |
|
722 input[i] = i | SIGN_BIT_32; |
|
723 } |
|
724 |
|
725 oil_convert_u16_u32(output, input, SIZE); |
|
726 |
|
727 for(i = 0; i<SIZE; i++) |
|
728 { |
|
729 if(i < SIZE/2) |
|
730 { |
|
731 if(output[i] != i) |
|
732 { |
|
733 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
734 assert_failed = 1; |
|
735 } |
|
736 } |
|
737 else |
|
738 { |
|
739 if(output[i] != MAX_UNSIGNED_INT16) |
|
740 { |
|
741 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT16,output[i]); |
|
742 assert_failed = 1; |
|
743 } |
|
744 } |
|
745 } |
|
746 } |
|
747 |
|
748 void test_oil_convert_u16_u8() |
|
749 { |
|
750 uint8_t input[SIZE]; |
|
751 uint16_t output[SIZE]; |
|
752 int i = 0; |
|
753 |
|
754 for(i=0; i<SIZE; i++) |
|
755 { |
|
756 if(i < SIZE/2) |
|
757 input[i] = i; |
|
758 else |
|
759 input[i] = i | SIGN_BIT_8; |
|
760 } |
|
761 |
|
762 oil_convert_u16_u8(output, input, SIZE); |
|
763 |
|
764 for(i = 0; i<SIZE; i++) |
|
765 { |
|
766 if(output[i] != input[i]) |
|
767 { |
|
768 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
769 assert_failed = 1; |
|
770 } |
|
771 } |
|
772 } |
|
773 |
|
774 void test_oil_convert_u32_f64() |
|
775 { |
|
776 uint32_t output[SIZE]; |
|
777 int i = 0; |
|
778 |
|
779 oil_convert_u32_f64(output, f64src, SIZE); |
|
780 |
|
781 for(i = 0; i<SIZE; i++) |
|
782 { |
|
783 if(output[i] != i) |
|
784 { |
|
785 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
786 assert_failed = 1; |
|
787 } |
|
788 } |
|
789 } |
|
790 |
|
791 void test_oil_convert_u32_s32() |
|
792 { |
|
793 int32_t input[SIZE]; |
|
794 uint32_t output[SIZE]; |
|
795 int i = 0; |
|
796 |
|
797 for(i=0; i<SIZE; i++) |
|
798 { |
|
799 if(i < SIZE/2) |
|
800 input[i] = i; |
|
801 else |
|
802 input[i] = i | 0x10000; |
|
803 } |
|
804 |
|
805 oil_convert_u32_s32(output, input, SIZE); |
|
806 |
|
807 for(i = 0; i<SIZE; i++) |
|
808 { |
|
809 if(output[i] != input[i]) |
|
810 { |
|
811 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
812 assert_failed = 1; |
|
813 } |
|
814 } |
|
815 } |
|
816 |
|
817 void test_oil_convert_u32_u16() |
|
818 { |
|
819 uint16_t input[SIZE]; |
|
820 uint32_t output[SIZE]; |
|
821 int i = 0; |
|
822 |
|
823 for(i=0; i<SIZE; i++) |
|
824 { |
|
825 if(i < SIZE/2) |
|
826 input[i] = i; |
|
827 else |
|
828 input[i] = i | SIGN_BIT_16; |
|
829 } |
|
830 |
|
831 oil_convert_u32_u16(output, input, SIZE); |
|
832 |
|
833 for(i = 0; i<SIZE; i++) |
|
834 { |
|
835 if(output[i] != input[i]) |
|
836 { |
|
837 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
838 assert_failed = 1; |
|
839 } |
|
840 } |
|
841 } |
|
842 |
|
843 void test_oil_convert_u32_u8() |
|
844 { |
|
845 uint8_t input[SIZE]; |
|
846 uint32_t output[SIZE]; |
|
847 int i = 0; |
|
848 |
|
849 for(i=0; i<SIZE; i++) |
|
850 { |
|
851 if(i < SIZE/2) |
|
852 input[i] = i; |
|
853 else |
|
854 input[i] = i | SIGN_BIT_8; |
|
855 } |
|
856 |
|
857 oil_convert_u32_u8(output, input, SIZE); |
|
858 |
|
859 for(i = 0; i<SIZE; i++) |
|
860 { |
|
861 if(output[i] != input[i]) |
|
862 { |
|
863 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
864 assert_failed = 1; |
|
865 } |
|
866 } |
|
867 } |
|
868 |
|
869 void test_oil_convert_u8_f32() |
|
870 { |
|
871 uint8_t output[SIZE]; |
|
872 int i = 0; |
|
873 |
|
874 oil_convert_u8_f32(output, f32src, SIZE); |
|
875 |
|
876 for(i = 0; i<SIZE; i++) |
|
877 { |
|
878 if(output[i] != i) |
|
879 { |
|
880 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
881 assert_failed = 1; |
|
882 } |
|
883 } |
|
884 } |
|
885 |
|
886 void test_oil_convert_u8_f64() |
|
887 { |
|
888 uint8_t output[SIZE]; |
|
889 int i = 0; |
|
890 |
|
891 oil_convert_u8_f64(output, f64src, SIZE); |
|
892 |
|
893 for(i = 0; i<SIZE; i++) |
|
894 { |
|
895 if(output[i] != i) |
|
896 { |
|
897 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
898 assert_failed = 1; |
|
899 } |
|
900 } |
|
901 } |
|
902 |
|
903 void test_oil_convert_u8_s16() |
|
904 { |
|
905 int16_t input[SIZE]; |
|
906 uint8_t output[SIZE]; |
|
907 int i = 0; |
|
908 |
|
909 for(i=0; i<SIZE; i++) |
|
910 { |
|
911 if(i < SIZE/2) |
|
912 input[i] = i; |
|
913 else |
|
914 input[i] = i | 0x100; |
|
915 } |
|
916 |
|
917 oil_convert_u8_s16(output, input, SIZE); |
|
918 |
|
919 for(i = 0; i<SIZE; i++) |
|
920 { |
|
921 if(i < SIZE/2) |
|
922 { |
|
923 if(output[i] != input[i]) |
|
924 { |
|
925 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
926 assert_failed = 1; |
|
927 } |
|
928 } |
|
929 else |
|
930 { |
|
931 if(output[i] != MAX_UNSIGNED_INT8) |
|
932 { |
|
933 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT8,output[i]); |
|
934 assert_failed = 1; |
|
935 } |
|
936 } |
|
937 } |
|
938 } |
|
939 |
|
940 void test_oil_convert_u8_s32() |
|
941 { |
|
942 int32_t input[SIZE]; |
|
943 uint8_t output[SIZE]; |
|
944 int i = 0; |
|
945 |
|
946 for(i=0; i<SIZE; i++) |
|
947 { |
|
948 if(i < SIZE/2) |
|
949 input[i] = i; |
|
950 else |
|
951 input[i] = i | 0x10000; |
|
952 } |
|
953 |
|
954 oil_convert_u8_s32(output, input, SIZE); |
|
955 |
|
956 for(i = 0; i<SIZE; i++) |
|
957 { |
|
958 if(i < SIZE/2) |
|
959 { |
|
960 if(output[i] != input[i]) |
|
961 { |
|
962 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
963 assert_failed = 1; |
|
964 } |
|
965 } |
|
966 else |
|
967 { |
|
968 if(output[i] != MAX_UNSIGNED_INT8) |
|
969 { |
|
970 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT8,output[i]); |
|
971 assert_failed = 1; |
|
972 } |
|
973 } |
|
974 } |
|
975 } |
|
976 |
|
977 void test_oil_convert_u8_s8() |
|
978 { |
|
979 int8_t input[SIZE]; |
|
980 uint8_t output[SIZE]; |
|
981 int i = 0; |
|
982 |
|
983 for(i=0; i<SIZE; i++) |
|
984 input[i] = i; |
|
985 |
|
986 oil_convert_u8_s8(output, input, SIZE); |
|
987 |
|
988 for(i = 0; i<SIZE; i++) |
|
989 { |
|
990 if(output[i] != i) |
|
991 { |
|
992 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,i,output[i]); |
|
993 assert_failed = 1; |
|
994 } |
|
995 } |
|
996 } |
|
997 |
|
998 void test_oil_convert_u8_u16() |
|
999 { |
|
1000 uint16_t input[SIZE]; |
|
1001 uint8_t output[SIZE]; |
|
1002 int i = 0; |
|
1003 |
|
1004 for(i=0; i<SIZE; i++) |
|
1005 { |
|
1006 if(i < SIZE/2) |
|
1007 input[i] = i; |
|
1008 else |
|
1009 input[i] = i | SIGN_BIT_16; |
|
1010 } |
|
1011 |
|
1012 oil_convert_u8_u16(output, input, SIZE); |
|
1013 |
|
1014 for(i = 0; i<SIZE; i++) |
|
1015 { |
|
1016 if(i < SIZE/2) |
|
1017 { |
|
1018 if(output[i] != input[i]) |
|
1019 { |
|
1020 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
1021 assert_failed = 1; |
|
1022 } |
|
1023 } |
|
1024 else if(output[i] != MAX_UNSIGNED_INT8) |
|
1025 { |
|
1026 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT8,output[i]); |
|
1027 assert_failed = 1; |
|
1028 } |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 void test_oil_convert_u8_u32() |
|
1033 { |
|
1034 uint32_t input[SIZE]; |
|
1035 uint8_t output[SIZE]; |
|
1036 int i = 0; |
|
1037 |
|
1038 for(i=0; i<SIZE; i++) |
|
1039 { |
|
1040 if(i < SIZE/2) |
|
1041 input[i] = i; |
|
1042 else |
|
1043 input[i] = i | SIGN_BIT_32; |
|
1044 } |
|
1045 |
|
1046 oil_convert_u8_u32(output, input, SIZE); |
|
1047 |
|
1048 for(i = 0; i<SIZE; i++) |
|
1049 { |
|
1050 if(i < SIZE/2) |
|
1051 { |
|
1052 if(output[i] != input[i]) |
|
1053 { |
|
1054 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,input[i],output[i]); |
|
1055 assert_failed = 1; |
|
1056 } |
|
1057 } |
|
1058 else if(output[i] != MAX_UNSIGNED_INT8) |
|
1059 { |
|
1060 std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,MAX_UNSIGNED_INT8,output[i]); |
|
1061 assert_failed = 1; |
|
1062 } |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 int main (int argc, char *argv[]) |
|
1067 { |
|
1068 oil_init(); |
|
1069 |
|
1070 std_log(LOG_FILENAME_LINE,"START oil_convert_s16_* TESTS"); |
|
1071 test_oil_convert_s16_f32(); |
|
1072 test_oil_convert_s16_f64(); |
|
1073 test_oil_convert_s16_s32(); |
|
1074 test_oil_convert_s16_s8(); |
|
1075 test_oil_convert_s16_u16(); |
|
1076 test_oil_convert_s16_u32(); |
|
1077 test_oil_convert_s16_u8(); |
|
1078 std_log(LOG_FILENAME_LINE,"END oil_convert_s16_* TESTS"); |
|
1079 |
|
1080 std_log(LOG_FILENAME_LINE,"START oil_convert_s32_* TESTS"); |
|
1081 test_oil_convert_s32_f64(); |
|
1082 test_oil_convert_s32_s16(); |
|
1083 test_oil_convert_s32_s8(); |
|
1084 test_oil_convert_s32_u16(); |
|
1085 test_oil_convert_s32_u32(); |
|
1086 test_oil_convert_s32_u8(); |
|
1087 std_log(LOG_FILENAME_LINE,"END oil_convert_s32_* TESTS"); |
|
1088 |
|
1089 std_log(LOG_FILENAME_LINE,"START oil_convert_s8_* TESTS"); |
|
1090 test_oil_convert_s8_f32(); |
|
1091 test_oil_convert_s8_f64(); |
|
1092 test_oil_convert_s8_s16(); |
|
1093 test_oil_convert_s8_s32(); |
|
1094 test_oil_convert_s8_u16(); |
|
1095 test_oil_convert_s8_u32(); |
|
1096 test_oil_convert_s8_u8(); |
|
1097 std_log(LOG_FILENAME_LINE,"END oil_convert_s8_* TESTS"); |
|
1098 |
|
1099 std_log(LOG_FILENAME_LINE,"START oil_convert_u16_* TESTS"); |
|
1100 test_oil_convert_u16_f32(); |
|
1101 test_oil_convert_u16_f64(); |
|
1102 test_oil_convert_u16_s16(); |
|
1103 test_oil_convert_u16_s32(); |
|
1104 test_oil_convert_u16_u32(); |
|
1105 test_oil_convert_u16_u8(); |
|
1106 std_log(LOG_FILENAME_LINE,"END oil_convert_u16_* TESTS"); |
|
1107 |
|
1108 std_log(LOG_FILENAME_LINE,"START oil_convert_u32_* TESTS"); |
|
1109 test_oil_convert_u32_f64(); |
|
1110 test_oil_convert_u32_s32(); |
|
1111 test_oil_convert_u32_u16(); |
|
1112 test_oil_convert_u32_u8(); |
|
1113 std_log(LOG_FILENAME_LINE,"END oil_convert_u32_* TESTS"); |
|
1114 |
|
1115 std_log(LOG_FILENAME_LINE,"START oil_convert_u8_* TESTS"); |
|
1116 test_oil_convert_u8_f32(); |
|
1117 test_oil_convert_u8_f64(); |
|
1118 test_oil_convert_u8_s16(); |
|
1119 test_oil_convert_u8_s32(); |
|
1120 test_oil_convert_u8_s8(); |
|
1121 test_oil_convert_u8_u16(); |
|
1122 test_oil_convert_u8_u32(); |
|
1123 std_log(LOG_FILENAME_LINE,"END oil_convert_u8_* TESTS"); |
|
1124 |
|
1125 if(assert_failed) |
|
1126 std_log(LOG_FILENAME_LINE,"Test Failed"); |
|
1127 else |
|
1128 std_log(LOG_FILENAME_LINE,"Test Successful"); |
|
1129 create_xml(0); |
|
1130 return 0; |
|
1131 } |
|
1132 |