summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/phoenix/test/stdlib/cmath.cpp
blob: f4703c61dd407fcb354c87f9674a7f4137785b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*=============================================================================
    Copyright (c) 2001-2007 Joel de Guzman
    Copyright (c) 2014      John Fletcher

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#include <cmath>
#include <boost/function.hpp>
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/stl/cmath.hpp>
#include <boost/core/lightweight_test.hpp>

int main()
{
    double eps = 0.000001;
    using namespace boost::phoenix::arg_names;
    boost::function<bool(double, double)> f = boost::phoenix::fabs(_1 - _2) < eps;

    double x = boost::phoenix::pow(_1,_2)(2.,2.);
    double y = boost::phoenix::atan2(_1,_2)(1.,1.);
    double z = boost::phoenix::tan(_1)(y);

    BOOST_TEST(f(0.0, 0 * eps));
    BOOST_TEST(!f(0.0, eps));
    BOOST_TEST(std::fabs(x-4.) < eps );
    BOOST_TEST(std::fabs(z-1.) < eps );
    return boost::report_errors();
}