Home | History | Annotate | Download | only in jni
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <math.h>
     18 #include <stdio.h>
     19 
     20 double foo(double a, double b)
     21 {
     22    return sin(a) + cos(b) + 4.9;
     23 }
     24 
     25 double d1 = M_PI;
     26 double d2 = 2.0;
     27 double d3 = -0.007;
     28 double d4 = 0.5;
     29 
     30 
     31 int main()
     32 {
     33     int fail_count = 0;
     34     {
     35         double d0 = foo(d1,d2);
     36         const double expected0 = 4.483853;
     37         printf("%lf\n", d0);
     38         fail_count += !(fabs(d0-expected0) < 0.00001);
     39     }
     40     {
     41         double d1 = __builtin_atan2(d3, d4);
     42         const double expected1 = -0.013999;
     43         printf("%lf\n", d1);
     44         fail_count += !(fabs(d1-expected1) < 0.00001);
     45     }
     46     return fail_count;
     47 }
     48