summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/yap/test/supplied_transforms.cpp
blob: fa70eb4396d18299fb7679fb2400042639b371e0 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2019 Paul Keir
//
// 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 <boost/yap/yap.hpp>

#include <boost/test/minimal.hpp>

namespace yap = boost::yap;

int test_main(int, char * [])
{
    // Test replacements(), which returns a transform object
    {
        using namespace boost::yap::literals;

        auto expr_in  = 1_p * 2_p;
        auto xform    = yap::replacements(6,9);
        auto expr_out = yap::transform(expr_in,xform);
        auto result   = yap::evaluate(expr_out);
        BOOST_CHECK(result == 54);
    }

    // Test evaluation(), which returns a transform object
    {
        using namespace boost::yap::literals;

        auto expr_in  = 1_p * 2_p;
        auto xform    = yap::evaluation(7,10);
        auto result   = yap::transform(expr_in,xform);
        BOOST_CHECK(result == 70);
    }

    // Test replace_placeholders(), which returns an expression 
    {
        using namespace boost::yap::literals;

        auto expr_in  = 1_p * 2_p;
        auto expr_out = yap::replace_placeholders(expr_in,8,11);
        auto result   = yap::evaluate(expr_out);
        BOOST_CHECK(result == 88);
    }

    return 0;
}