1 // Copyright (C) 2016-2018 T. Zachary Laine 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/expression.hpp> 7 8 #include <boost/test/minimal.hpp> 9 10 #include <sstream> 11 12 13 template<typename T> 14 using term = boost::yap::terminal<boost::yap::expression, T>; 15 16 namespace yap = boost::yap; 17 18 test_main(int,char * [])19int test_main(int, char * []) 20 { 21 { 22 term<double> unity{1.0}; 23 24 { 25 auto expr = 26 unity + unity + unity + unity + unity + unity + unity + unity; 27 double result = boost::yap::evaluate(expr); 28 BOOST_CHECK(result == 8.0); 29 } 30 31 { 32 auto expr = 33 unity + unity + unity + unity + unity + unity + unity + unity + 34 unity + unity + unity + unity + unity + unity + unity + unity + 35 unity + unity + unity + unity + unity + unity + unity + unity + 36 unity + unity + unity + unity + unity + unity + unity + unity + 37 38 unity + unity + unity + unity + unity + unity + unity + unity + 39 unity + unity + unity + unity + unity + unity + unity + unity + 40 unity + unity + unity + unity + unity + unity + unity + unity + 41 unity + unity + unity + unity + unity + unity + unity + unity; 42 double result = boost::yap::evaluate(expr); 43 BOOST_CHECK(result == 64.0); 44 } 45 46 #if 0 // This makes the Travis VMs barf. 47 { 48 auto expr = 49 unity + unity + unity + unity + unity + unity + unity + unity + 50 unity + unity + unity + unity + unity + unity + unity + unity + 51 unity + unity + unity + unity + unity + unity + unity + unity + 52 unity + unity + unity + unity + unity + unity + unity + unity + 53 54 unity + unity + unity + unity + unity + unity + unity + unity + 55 unity + unity + unity + unity + unity + unity + unity + unity + 56 unity + unity + unity + unity + unity + unity + unity + unity + 57 unity + unity + unity + unity + unity + unity + unity + unity; 58 double result = boost::yap::evaluate( 59 expr + expr + expr + expr + expr + expr + expr + expr + 60 expr + expr + expr + expr + expr + expr + expr + expr + 61 expr + expr + expr + expr + expr + expr + expr + expr + 62 expr + expr + expr + expr + expr + expr + expr + expr 63 ); 64 BOOST_CHECK(result == 64.0 * 32.0); 65 } 66 #endif 67 } 68 69 return 0; 70 } 71