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 #include <android/api-level.h> 17 #include <features.h> 18 #include <math.h> 19 #include <stdio.h> 20 21 long double ld, ld1, ldn; 22 double d, d1, dn; 23 float f, f1, fn; 24 int fail_count = 0; 25 26 void TEST_EQ(long double a, long double b) 27 { 28 long double diff = a - b; 29 if (diff < 0) 30 diff = -diff; 31 if (diff > 0.0000001) 32 fail_count ++; 33 } 34 35 int main() 36 { 37 #if __ANDROID_API__ >= 9 38 #if __ANDROID_API__ < 20 39 sincosl(0.73, &ld, &ld1); 40 sincos(0.72, &d, &d1); 41 sincosf(0.71f, &f, &f1); 42 TEST_EQ(ld, 0.6668696L); 43 TEST_EQ(ld1, 0.7451744L); 44 TEST_EQ(d, 0.6593847); 45 TEST_EQ(d1, 0.7518057); 46 TEST_EQ(f, 0.6518338f); 47 TEST_EQ(f1, 0.7583619f); 48 #endif 49 #if __ANDROID_API__ >= 13 50 ldn = nanl(""); 51 dn = nan(""); 52 fn = nanf(""); 53 #if __ANDROID_API__ >= 18 54 ld = 1234L; 55 ld = logbl(ld); 56 TEST_EQ(ld, 10L); 57 ld = log2l(ld); 58 TEST_EQ(ld, 3.321928L); 59 d = 56.78; 60 d = log2(d); 61 TEST_EQ(d, 5.827311); 62 f = 0.9012f; 63 f = log2f(f); 64 TEST_EQ(f, -.1500808f); 65 ld = nexttowardl(ld, 0); 66 d = nexttoward(d, 0); 67 #endif 68 #endif 69 #endif 70 if (fail_count) 71 printf("fail_count = %d\n", fail_count); 72 73 return fail_count; 74 } 75