Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / simdmathlibrary / spu / tests / absi4.c
1 /* Test absi4 for SPU
2    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3    All rights reserved.
4
5    Redistribution and use in source and binary forms,
6    with or without modification, are permitted provided that the
7    following conditions are met:
8     * Redistributions of source code must retain the above copyright
9       notice, this list of conditions and the following disclaimer.
10     * Redistributions in binary form must reproduce the above copyright
11       notice, this list of conditions and the following disclaimer in the
12       documentation and/or other materials provided with the distribution.
13     * Neither the name of the Sony Computer Entertainment Inc nor the names
14       of its contributors may be used to endorse or promote products derived
15       from this software without specific prior written permission.
16
17    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27    POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include "simdmath.h"
35 #include "common-test.h"
36 #include "testutils.h"
37
38 int main()
39 {
40    TEST_SET_START("20040908101807EJL","EJL", "abs");
41    
42    int x0n = hide_int(0);
43    int x0p = hide_int(0);
44    int x1n = hide_int(-1);
45    int x1p = hide_int(1);
46    int x2n = hide_int(-83532);
47    int x2p = hide_int(83532);
48
49    vec_int4 x0n_v = spu_splats(x0n);
50    vec_int4 x0p_v = spu_splats(x0p);
51    vec_int4 x1n_v = spu_splats(x1n);
52    vec_int4 x1p_v = spu_splats(x1p);
53    vec_int4 x2n_v = spu_splats(x2n);
54    vec_int4 x2p_v = spu_splats(x2p);
55    
56    int res;
57    vec_int4 res_v;
58
59    TEST_START("absi4");
60    res_v = absi4(x0n_v);
61    TEST_CHECK("20040908103824EJL", allequal_int4( res_v, x0p_v ), 0);
62    res_v = absi4(x0p_v);
63    TEST_CHECK("20040908103903EJL", allequal_int4( res_v, x0p_v ), 0);
64    res_v = absi4(x1n_v);
65    TEST_CHECK("20040908103905EJL", allequal_int4( res_v, x1p_v ), 0);
66    res_v = absi4(x1p_v);
67    TEST_CHECK("20040908114003EJL", allequal_int4( res_v, x1p_v ), 0);
68    res_v = absi4(x2n_v);
69    TEST_CHECK("20040908114714EJL", allequal_int4( res_v, x2p_v ), 0);
70    res_v = absi4(x2p_v);
71    TEST_CHECK("20040908114715EJL", allequal_int4( res_v, x2p_v ), 0);
72    
73    TEST_START("abs");
74    res = abs(x0n);
75    TEST_CHECK("20040908114718EJL", res == x0p, 0);
76    res = abs(x0p);
77    TEST_CHECK("20040908114719EJL", res == x0p, 0);
78    res = abs(x1n);
79    TEST_CHECK("20040908114720EJL", res == x1p, 0);
80    res = abs(x1p);
81    TEST_CHECK("20040908114721EJL", res == x1p, 0);
82    res = abs(x2n);
83    TEST_CHECK("20040908114722EJL", res == x2p, 0);
84    res = abs(x2p);                  
85    TEST_CHECK("20040908114723EJL", res == x2p, 0);
86    
87    TEST_SET_DONE();
88    
89    TEST_EXIT();
90 }