| 1 | // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. |
| 2 | |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER |
| 7 | # include BOOST_QVM_TEST_SINGLE_HEADER |
| 8 | #else |
| 9 | # include <boost/qvm/math.hpp> |
| 10 | #endif |
| 11 | |
| 12 | #include <boost/core/lightweight_test.hpp> |
| 13 | #include "test_qvm.hpp" |
| 14 | #include <stdlib.h> |
| 15 | |
| 16 | namespace |
| 17 | { |
| 18 | template <class T> |
| 19 | void |
| 20 | test1( T (*f1)(T), T (*f2)(T) ) |
| 21 | { |
| 22 | for( int i=0; i!=100; ++i ) |
| 23 | { |
| 24 | T a = T(rand()) / T(RAND_MAX); |
| 25 | BOOST_QVM_TEST_CLOSE(double(f1(a)), double(f2(a)),0.00001); |
| 26 | } |
| 27 | } |
| 28 | template <class T,class U> |
| 29 | void |
| 30 | test2( T (*f1)(T,U), T (*f2)(T,U) ) |
| 31 | { |
| 32 | for( int i=0; i!=100; ++i ) |
| 33 | { |
| 34 | T a = T(rand()) / T(RAND_MAX); |
| 35 | T b = T(rand()) / T(RAND_MAX); |
| 36 | BOOST_QVM_TEST_CLOSE(double(f1(a,b)), double(f2(a,b)),0.00001); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | int |
| 42 | main() |
| 43 | { |
| 44 | test1<float>(f1: &boost::qvm::acos<float>, f2: &::acosf); |
| 45 | test1<float>(f1: &boost::qvm::asin<float>, f2: &::asinf); |
| 46 | test1<float>(f1: &boost::qvm::atan<float>, f2: &::atanf); |
| 47 | test2<float,float>(f1: &boost::qvm::atan2<float>, f2: &::atan2f); |
| 48 | test1<float>(f1: &boost::qvm::cos<float>, f2: &::cosf); |
| 49 | test1<float>(f1: &boost::qvm::sin<float>, f2: &::sinf); |
| 50 | test1<float>(f1: &boost::qvm::tan<float>, f2: &::tanf); |
| 51 | test1<float>(f1: &boost::qvm::cosh<float>, f2: &::coshf); |
| 52 | test1<float>(f1: &boost::qvm::sinh<float>, f2: &::sinhf); |
| 53 | test1<float>(f1: &boost::qvm::tanh<float>, f2: &::tanhf); |
| 54 | test1<float>(f1: &boost::qvm::exp<float>, f2: &::expf); |
| 55 | test1<float>(f1: &boost::qvm::log<float>, f2: &::logf); |
| 56 | test1<float>(f1: &boost::qvm::log10<float>, f2: &::log10f); |
| 57 | test2<float,float>(f1: &boost::qvm::mod<float>, f2: &::fmodf); |
| 58 | test2<float,float>(f1: &boost::qvm::pow<float>, f2: &::powf); |
| 59 | test1<float>(f1: &boost::qvm::sqrt<float>, f2: &::sqrtf); |
| 60 | test1<float>(f1: &boost::qvm::ceil<float>, f2: &::ceilf); |
| 61 | test1<float>(f1: &boost::qvm::abs<float>, f2: &::fabsf); |
| 62 | test1<float>(f1: &boost::qvm::floor<float>, f2: &::floorf); |
| 63 | test2<float, int>(f1: &boost::qvm::ldexp<float>, f2: &::ldexpf); |
| 64 | |
| 65 | test1<double>(f1: &boost::qvm::acos<double>, f2: &::acos); |
| 66 | test1<double>(f1: &boost::qvm::asin<double>, f2: &::asin); |
| 67 | test1<double>(f1: &boost::qvm::atan<double>, f2: &::atan); |
| 68 | test2<double,double>(f1: &boost::qvm::atan2<double>, f2: &::atan2); |
| 69 | test1<double>(f1: &boost::qvm::cos<double>, f2: &::cos); |
| 70 | test1<double>(f1: &boost::qvm::sin<double>, f2: &::sin); |
| 71 | test1<double>(f1: &boost::qvm::tan<double>, f2: &::tan); |
| 72 | test1<double>(f1: &boost::qvm::cosh<double>, f2: &::cosh); |
| 73 | test1<double>(f1: &boost::qvm::sinh<double>, f2: &::sinh); |
| 74 | test1<double>(f1: &boost::qvm::tanh<double>, f2: &::tanh); |
| 75 | test1<double>(f1: &boost::qvm::exp<double>, f2: &::exp); |
| 76 | test1<double>(f1: &boost::qvm::log<double>, f2: &::log); |
| 77 | test1<double>(f1: &boost::qvm::log10<double>, f2: &::log10); |
| 78 | test2<double,double>(f1: &boost::qvm::mod<double>, f2: &::fmod); |
| 79 | test2<double,double>(f1: &boost::qvm::pow<double>, f2: &::pow); |
| 80 | test1<double>(f1: &boost::qvm::sqrt<double>, f2: &::sqrt); |
| 81 | test1<double>(f1: &boost::qvm::ceil<double>, f2: &::ceil); |
| 82 | test1<double>(f1: &boost::qvm::abs<double>, f2: &::fabs); |
| 83 | test1<double>(f1: &boost::qvm::floor<double>, f2: &::floor); |
| 84 | test2<double, int>(f1: &boost::qvm::ldexp<double>, f2: &::ldexp); |
| 85 | |
| 86 | test1<long double>(f1: &boost::qvm::acos<long double>, f2: &::acosl); |
| 87 | test1<long double>(f1: &boost::qvm::asin<long double>, f2: &::asinl); |
| 88 | test1<long double>(f1: &boost::qvm::atan<long double>, f2: &::atanl); |
| 89 | test2<long double,long double>(f1: &boost::qvm::atan2<long double>, f2: &::atan2l); |
| 90 | test1<long double>(f1: &boost::qvm::cos<long double>, f2: &::cosl); |
| 91 | test1<long double>(f1: &boost::qvm::sin<long double>, f2: &::sinl); |
| 92 | test1<long double>(f1: &boost::qvm::tan<long double>, f2: &::tanl); |
| 93 | test1<long double>(f1: &boost::qvm::cosh<long double>, f2: &::coshl); |
| 94 | test1<long double>(f1: &boost::qvm::sinh<long double>, f2: &::sinhl); |
| 95 | test1<long double>(f1: &boost::qvm::tanh<long double>, f2: &::tanhl); |
| 96 | test1<long double>(f1: &boost::qvm::exp<long double>, f2: &::expl); |
| 97 | test1<long double>(f1: &boost::qvm::log<long double>, f2: &::logl); |
| 98 | test1<long double>(f1: &boost::qvm::log10<long double>, f2: &::log10l); |
| 99 | test2<long double,long double>(f1: &boost::qvm::mod<long double>, f2: &::fmodl); |
| 100 | test2<long double,long double>(f1: &boost::qvm::pow<long double>, f2: &::powl); |
| 101 | test1<long double>(f1: &boost::qvm::sqrt<long double>, f2: &::sqrtl); |
| 102 | test1<long double>(f1: &boost::qvm::ceil<long double>, f2: &::ceill); |
| 103 | test1<long double>(f1: &boost::qvm::abs<long double>, f2: &::fabsl); |
| 104 | test1<long double>(f1: &boost::qvm::floor<long double>, f2: &::floorl); |
| 105 | test2<long double, int>(f1: &boost::qvm::ldexp<long double>, f2: &::ldexpl); |
| 106 | |
| 107 | return boost::report_errors(); |
| 108 | } |
| 109 | |