#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.
Functions | |
BOOST_AUTO_TEST_CASE (test_basics) | |
BOOST_AUTO_TEST_CASE (test_list) | |
BOOST_AUTO_TEST_CASE (test_negate) | |
BOOST_AUTO_TEST_CASE (test_add) | |
BOOST_AUTO_TEST_CASE (test_subtract) | |
BOOST_AUTO_TEST_CASE (test_multiply) | |
BOOST_AUTO_TEST_CASE (test_divide) | |
BOOST_AUTO_TEST_CASE (test_mix) | |
BOOST_AUTO_TEST_CASE (test_var) | |
BOOST_AUTO_TEST_CASE (test_function_call) | |
BOOST_AUTO_TEST_CASE (test_copy) | |
BOOST_AUTO_TEST_SUITE_END () |
BOOST_AUTO_TEST_CASE | ( | test_copy | ) |
Definition at line 113 of file test_node.cpp.
References node::evaluate().
00114 { 00115 node n(node(node(1), '+', node(2))); 00116 { 00117 node m(n); 00118 n = node('-', m); 00119 BOOST_CHECK_EQUAL(3.0, m.evaluate()); 00120 } 00121 { 00122 node a; 00123 a = n; 00124 BOOST_CHECK_EQUAL(-3.0, a.evaluate()); 00125 } 00126 BOOST_CHECK_EQUAL(-3.0, n.evaluate()); 00127 }
BOOST_AUTO_TEST_CASE | ( | test_function_call | ) |
Definition at line 100 of file test_node.cpp.
References node::evaluate(), and set_function().
00101 { 00102 identifier_list parms; 00103 parms.push_back("a"); 00104 parms.push_back("b"); 00105 set_function("test", node(parms, node(node("a"), '+', node("b", node_list())))); 00106 node_list args; 00107 args.push_back(node(1.0)); 00108 args.push_back(node(2.0)); 00109 node call("test", args); 00110 BOOST_CHECK_EQUAL(3.0, call.evaluate()); 00111 }
BOOST_AUTO_TEST_CASE | ( | test_var | ) |
Definition at line 94 of file test_node.cpp.
References get_variable(), and set_variable().
00095 { 00096 set_variable("half", node(node(1.0), '/', node(2))); 00097 BOOST_CHECK_EQUAL(0.5, get_variable("half").evaluate()); 00098 }
BOOST_AUTO_TEST_CASE | ( | test_mix | ) |
Definition at line 67 of file test_node.cpp.
References node::evaluate().
00068 { 00069 node a(node(1.5), '*', node(2.0)); 00070 BOOST_CHECK_EQUAL(3.0, a.evaluate()); 00071 00072 node b(node(3.0), '/', node(1.5)); 00073 BOOST_CHECK_EQUAL(2.0, b.evaluate()); 00074 00075 node c(a, '+', b); 00076 BOOST_CHECK_EQUAL(5.0, c.evaluate()); 00077 00078 node d(node(10), '-', node(3)); 00079 BOOST_CHECK_EQUAL(7.0, d.evaluate()); 00080 00081 node e('-', node(1.0)); 00082 BOOST_CHECK_EQUAL(-1.0, e.evaluate()); 00083 00084 node f(node(2), '*', e); 00085 BOOST_CHECK_EQUAL(-2.0, f.evaluate()); 00086 00087 node g(d, '+', f); 00088 BOOST_CHECK_EQUAL(5.0, g.evaluate()); 00089 00090 node h(c, '-', g); 00091 BOOST_CHECK_EQUAL(0.0, h.evaluate()); 00092 }
BOOST_AUTO_TEST_CASE | ( | test_divide | ) |
BOOST_AUTO_TEST_CASE | ( | test_multiply | ) |
BOOST_AUTO_TEST_CASE | ( | test_subtract | ) |
BOOST_AUTO_TEST_CASE | ( | test_add | ) |
BOOST_AUTO_TEST_CASE | ( | test_negate | ) |
Definition at line 32 of file test_node.cpp.
References node::evaluate().
00033 { 00034 node n(1.0); 00035 node neg('-', n); 00036 BOOST_CHECK_EQUAL(-1.0, neg.evaluate()); 00037 }
BOOST_AUTO_TEST_CASE | ( | test_list | ) |
Definition at line 19 of file test_node.cpp.
00020 { 00021 node_list nl; 00022 nl.push_back(node(1.0)); 00023 nl.push_back(node(2.0)); 00024 nl.push_back(node(nl[0], '*', nl[1])); 00025 BOOST_CHECK_EQUAL(3, nl.size()); 00026 node_list copy(nl); 00027 nl.clear(); 00028 BOOST_CHECK_EQUAL(3, copy.size()); 00029 BOOST_CHECK_EQUAL("2", copy.at(1).to_string()); 00030 }
BOOST_AUTO_TEST_CASE | ( | test_basics | ) |
Definition at line 12 of file test_node.cpp.
References node::evaluate(), and node::to_string().
00013 { 00014 node n(1.0); 00015 BOOST_CHECK_EQUAL(1.0, n.evaluate()); 00016 BOOST_CHECK_EQUAL("1", n.to_string()); 00017 }
BOOST_AUTO_TEST_SUITE_END | ( | ) |