#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
#include <boost/test/auto_unit_test.hpp>
#include "node.hpp"
#include "variables.hpp"
Go to the source code of this file.
BOOST_AUTO_TEST_CASE |
( |
test_basics |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
test_list |
| ) |
|
Definition at line 21 of file test_node.cpp.
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());
std::vector< node > node_list
A sequence of nodes.
BOOST_AUTO_TEST_CASE |
( |
test_negate |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
test_add |
| ) |
|
Definition at line 41 of file test_node.cpp.
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());
BOOST_AUTO_TEST_CASE |
( |
test_subtract |
| ) |
|
Definition at line 48 of file test_node.cpp.
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());
BOOST_AUTO_TEST_CASE |
( |
test_multiply |
| ) |
|
Definition at line 55 of file test_node.cpp.
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());
BOOST_AUTO_TEST_CASE |
( |
test_divide |
| ) |
|
Definition at line 62 of file test_node.cpp.
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());
BOOST_AUTO_TEST_CASE |
( |
test_mix |
| ) |
|
Definition at line 69 of file test_node.cpp.
References node::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());
BOOST_AUTO_TEST_CASE |
( |
test_var |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
test_function_call |
| ) |
|
Definition at line 102 of file test_node.cpp.
References node::evaluate(), and set_function().
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());
std::vector< std::string > identifier_list
A sequence of identifiers (e.g., parameter names).
void set_function(std::string const &name, node value)
std::vector< node > node_list
A sequence of nodes.
BOOST_AUTO_TEST_CASE |
( |
test_copy |
| ) |
|
Definition at line 115 of file test_node.cpp.
References node::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_SUITE |
( |
node_test |
| ) |
|
BOOST_AUTO_TEST_SUITE_END |
( |
| ) |
|