Line data Source code
1 : #define BOOST_TEST_MODULE variables
2 : #include <boost/test/included/unit_test.hpp>
3 : #include "exprtest.hpp"
4 :
5 : double const x = 1;
6 : double const y = 2;
7 :
8 14 : static std::map<std::string, double> symtab() {
9 14 : std::map<std::string, double> symtab;
10 14 : symtab.insert(std::make_pair("x", x));
11 14 : symtab.insert(std::make_pair("y", y));
12 14 : symtab.insert(std::make_pair("e", -1));
13 14 : return symtab;
14 : }
15 :
16 6 : SYMEXPRTEST(var1, "x+y" , symtab(), x+y)
17 6 : SYMEXPRTEST(var2, "x-y" , symtab(), x-y)
18 6 : SYMEXPRTEST(var3, "x*y" , symtab(), x*y)
19 6 : SYMEXPRTEST(var4, "x/y" , symtab(), x/y);
20 6 : SYMEXPRTEST(var5, "x%y" , symtab(), std::fmod(x,y));
21 6 : SYMEXPRTEST(var6, "x**y", symtab(), std::pow(x,y));
22 :
23 : // Constants have higher priority than variables of the same name
24 6 : SYMEXPRTEST(var7, "e", symtab(), boost::math::constants::e<double>())
|