]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/yap/test/supplied_transforms.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / yap / test / supplied_transforms.cpp
1 // Copyright (C) 2019 Paul Keir
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/yap/yap.hpp>
7
8 #include <boost/core/lightweight_test.hpp>
9
10 namespace yap = boost::yap;
11
12 int main()
13 {
14 // Test replacements(), which returns a transform object
15 {
16 using namespace boost::yap::literals;
17
18 auto expr_in = 1_p * 2_p;
19
20 auto xform = yap::replacements(6,9);
21 auto expr_out = yap::transform(expr_in,xform);
22 auto result = yap::evaluate(expr_out);
23 BOOST_TEST(result == 54);
24
25 #ifndef _MSC_VER // Tsk, tsk.
26 constexpr auto cxform = yap::replacements(6);
27 constexpr auto cexpr_out = yap::transform(1_p,cxform);
28 constexpr auto cresult = yap::evaluate(cexpr_out);
29 static_assert(cresult == 6,"");
30 #endif
31 }
32
33 // Test evaluation(), which returns a transform object
34 {
35 using namespace boost::yap::literals;
36
37 auto expr_in = 1_p * 2_p;
38
39 auto xform = yap::evaluation(7,10);
40 auto result = yap::transform(expr_in,xform);
41 BOOST_TEST(result == 70);
42
43 #ifndef _MSC_VER // Tsk, tsk.
44 constexpr auto cxform = yap::evaluation(7);
45 constexpr auto cresult = yap::transform(1_p,cxform);
46 static_assert(cresult == 7,"");
47 #endif
48 }
49
50 // Test replace_placeholders(), which returns an expression
51 {
52 using namespace boost::yap::literals;
53
54 auto expr_in = 1_p * 2_p;
55
56 auto expr_out = yap::replace_placeholders(expr_in,8,11);
57 auto result = yap::evaluate(expr_out);
58 BOOST_TEST(result == 88);
59
60 #ifndef _MSC_VER // Tsk, tsk.
61 constexpr auto cexpr_out = yap::replace_placeholders(1_p,8);
62 constexpr auto cresult = yap::evaluate(cexpr_out);
63 static_assert(cresult == 8,"");
64 #endif
65 }
66
67 return boost::report_errors();
68 }
69