aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/tests/eina_test_fp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/tests/eina_test_fp.c')
-rw-r--r--libraries/eina/src/tests/eina_test_fp.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/libraries/eina/src/tests/eina_test_fp.c b/libraries/eina/src/tests/eina_test_fp.c
new file mode 100644
index 0000000..bdb3100
--- /dev/null
+++ b/libraries/eina/src/tests/eina_test_fp.c
@@ -0,0 +1,93 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2010 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include <math.h>
24#include <stdio.h>
25
26#include "eina_suite.h"
27#include "Eina.h"
28
29START_TEST(eina_fp_cos)
30{
31 Eina_F32p32 fc;
32 Eina_F32p32 fl;
33 Eina_F32p32 step;
34 Eina_F32p32 fresult;
35 double dc;
36 double dresult;
37 double delta;
38
39 fail_if(!eina_init());
40
41 fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
42 step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
43
44 for (fc = 0; fc < fl; fc += step)
45 {
46 fresult = eina_f32p32_cos(fc);
47 dc = eina_f32p32_double_to(fc);
48 dresult = cos(dc);
49
50 delta = fabs(dresult - eina_f32p32_double_to(fresult));
51 fail_if(delta > 0.005);
52 }
53
54 eina_shutdown();
55}
56END_TEST
57
58START_TEST(eina_fp_sin)
59{
60 Eina_F32p32 fc;
61 Eina_F32p32 fl;
62 Eina_F32p32 step;
63 Eina_F32p32 fresult;
64 double dc;
65 double dresult;
66 double delta;
67
68 fail_if(!eina_init());
69
70 fl = eina_f32p32_scale(EINA_F32P32_PI, 4);
71 step = eina_f32p32_div(fl, eina_f32p32_int_from(2048));
72
73 for (fc = 0; fc < fl; fc += step)
74 {
75 fresult = eina_f32p32_sin(fc);
76 dc = eina_f32p32_double_to(fc);
77 dresult = sin(dc);
78
79 delta = fabs(dresult - eina_f32p32_double_to(fresult));
80 fail_if(delta > 0.005);
81 }
82
83
84 eina_shutdown();
85}
86END_TEST
87
88void
89eina_test_fp(TCase *tc)
90{
91 tcase_add_test(tc, eina_fp_cos);
92 tcase_add_test(tc, eina_fp_sin);
93}