7 #include <boost/test/auto_unit_test.hpp>
12 BOOST_AUTO_TEST_SUITE(node_test)
17 BOOST_CHECK_EQUAL(1.0, n.
evaluate());
24 nl.push_back(
node(1.0));
25 nl.push_back(
node(2.0));
26 nl.push_back(
node(nl[0],
'*', nl[1]));
27 BOOST_CHECK_EQUAL(3, nl.size());
30 BOOST_CHECK_EQUAL(3, copy.size());
31 BOOST_CHECK_EQUAL(
"2", copy.at(1).to_string());
38 BOOST_CHECK_EQUAL(-1.0, neg.
evaluate());
43 node a(1.0), b(2.0), c(3.0);
44 BOOST_CHECK_EQUAL(3.0,
node(a,
'+', b).evaluate());
45 BOOST_CHECK_EQUAL(6.0,
node(
node(a,
'+', b),
'+', c).evaluate());
50 node a(1.0), b(2.0), c(3.0);
51 BOOST_CHECK_EQUAL(1.0,
node(c,
'-', b).evaluate());
52 BOOST_CHECK_EQUAL(-4.0,
node(
node(a,
'-', b),
'-', c).evaluate());
57 node a(1.0), b(2.0), c(3.0);
58 BOOST_CHECK_EQUAL(3.0,
node(a,
'*', c).evaluate());
59 BOOST_CHECK_EQUAL(6.0,
node(
node(a,
'*', b),
'*', c).evaluate());
64 node a(1.0), b(2.0), c(6.0);
65 BOOST_CHECK_EQUAL(0.5,
node(a,
'/', b).evaluate());
66 BOOST_CHECK_EQUAL(3.0,
node(
node(c,
'/', a),
'/', b).evaluate());
72 BOOST_CHECK_EQUAL(3.0, a.
evaluate());
75 BOOST_CHECK_EQUAL(2.0, b.evaluate());
78 BOOST_CHECK_EQUAL(5.0, c.evaluate());
81 BOOST_CHECK_EQUAL(7.0, d.evaluate());
84 BOOST_CHECK_EQUAL(-1.0, e.evaluate());
87 BOOST_CHECK_EQUAL(-2.0, f.evaluate());
90 BOOST_CHECK_EQUAL(5.0, g.evaluate());
93 BOOST_CHECK_EQUAL(0.0, h.evaluate());
105 parms.push_back(
"a");
106 parms.push_back(
"b");
109 args.push_back(
node(1.0));
110 args.push_back(
node(2.0));
111 node call(
"test", args);
112 BOOST_CHECK_EQUAL(3.0, call.
evaluate());
121 BOOST_CHECK_EQUAL(3.0, m.
evaluate());
126 BOOST_CHECK_EQUAL(-3.0, a.
evaluate());
128 BOOST_CHECK_EQUAL(-3.0, n.
evaluate());
BOOST_AUTO_TEST_CASE(test_basics)
std::vector< std::string > identifier_list
A sequence of identifiers (e.g., parameter names).
BOOST_AUTO_TEST_SUITE_END()
void set_variable(std::string const &name, node value)
void set_function(std::string const &name, node value)
std::string to_string() const
std::vector< node > node_list
A sequence of nodes.
node get_variable(std::string const &name)