add some math tests
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12718 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e3b75692e9
commit
5c8563d142
@ -18,3 +18,4 @@ SEARCH on [ FGristFiles
|
|||||||
] = [ FDirName $(OBOS_TOP) src system libroot posix ] ;
|
] = [ FDirName $(OBOS_TOP) src system libroot posix ] ;
|
||||||
|
|
||||||
SubInclude OBOS_TOP src tests kernel libroot posix bonnie ;
|
SubInclude OBOS_TOP src tests kernel libroot posix bonnie ;
|
||||||
|
SubInclude OBOS_TOP src tests kernel libroot posix math ;
|
||||||
|
27
src/tests/kernel/libroot/posix/math/Jamfile
Normal file
27
src/tests/kernel/libroot/posix/math/Jamfile
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
SubDir OBOS_TOP src tests kernel libroot posix math ;
|
||||||
|
|
||||||
|
UsePrivateHeaders libroot ;
|
||||||
|
SubDirHdrs [ FDirName $(OBOS_TOP) src system libroot posix glibc ] ;
|
||||||
|
SubDirC++Flags -mieee-fp ;
|
||||||
|
|
||||||
|
MATH_SOURCES =
|
||||||
|
acosh.c asincos.c asinh.c atan.c
|
||||||
|
atan2.c atanh.c cabs.c cbrt.c
|
||||||
|
ceilf.c cosh.c erf.c exp.c
|
||||||
|
exp__E.c expm1.c floatmath.c floor.c
|
||||||
|
floorf.c fmod.c gamma.c ieee.c
|
||||||
|
j0.c j1.c jn.c lgamma.c
|
||||||
|
log.c log10.c log1p.c log__L.c
|
||||||
|
math_globals.c pow.c
|
||||||
|
sincos.c sinh.c tan.c tanh.c
|
||||||
|
;
|
||||||
|
|
||||||
|
SimpleTest math_test
|
||||||
|
: math_test.cpp $(MATH_SOURCES)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
# Tell Jam where to find these sources
|
||||||
|
SEARCH on [ FGristFiles
|
||||||
|
$(MATH_SOURCES)
|
||||||
|
] = [ FDirName $(OBOS_TOP) src system libroot posix math ] ;
|
47
src/tests/kernel/libroot/posix/math/math_test.cpp
Normal file
47
src/tests/kernel/libroot/posix/math/math_test.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005, Andrew Bachmann, andrewbachmann@myrealbox.com
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <OS.h>
|
||||||
|
#include <image.h>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
static double (*be_sin)(double);
|
||||||
|
static double (*be_cos)(double);
|
||||||
|
|
||||||
|
static image_id
|
||||||
|
get_libroot_id()
|
||||||
|
{
|
||||||
|
image_info info;
|
||||||
|
int32 cookie = 0;
|
||||||
|
while (get_next_image_info(0, &cookie, &info) == B_OK) {
|
||||||
|
if (strcmp(info.name, "/boot/beos/system/lib/libroot.so") == 0) {
|
||||||
|
return info.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
image_id libroot = get_libroot_id();
|
||||||
|
assert(get_image_symbol(libroot, "sin", B_SYMBOL_TYPE_TEXT, (void**)&be_sin) == B_OK);
|
||||||
|
assert(get_image_symbol(libroot, "cos", B_SYMBOL_TYPE_TEXT, (void**)&be_cos) == B_OK);
|
||||||
|
|
||||||
|
fprintf(stdout, "value\t\tsin(value)\tbe_sin(value)\tcos(value)\tbe_cos(value)\n");
|
||||||
|
status_t result = B_OK;
|
||||||
|
for (int i = -10 ; i < 10 ; i++) {
|
||||||
|
double f = (double)i;
|
||||||
|
fprintf(stdout, "%0.10f\t%0.10f\t%0.10f\t%0.10f\t%0.10f\n",
|
||||||
|
f, sin(f), be_sin(f), cos(f), be_cos(f));
|
||||||
|
if ((sin(f) != be_sin(f)) || (cos(f) != be_cos(f))) {
|
||||||
|
result = B_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user