7 #include <boost/test/unit_test.hpp>
15 std::istringstream in(
"1\n3.14159\n1.23e45\n45.67e+8\n");
16 std::ostringstream out;
18 BOOST_CHECK_EQUAL(
"> 1\n> 3.14159\n> 1.23e+45\n> 4.567e+09\n> ", out.str());
23 std::istringstream in(
"-1\n-3.14159\n-1.23e-45\n-34.56e-7\n");
24 std::ostringstream out;
26 BOOST_CHECK_EQUAL(
"> -1\n> -3.14159\n> -1.23e-45\n> -3.456e-06\n> ", out.str());
31 std::istringstream in(
"1 + 2\n1 + 2 + 3");
32 std::ostringstream out;
34 BOOST_CHECK_EQUAL(
"> 3\n> 6\n> ", out.str());
39 std::istringstream in(
"1 - 2\n5 - 1 - 2");
40 std::ostringstream out;
42 BOOST_CHECK_EQUAL(
"> -1\n> 2\n> ", out.str());
47 std::istringstream in(
"1 * 2\n5 * 2 * 1.5");
48 std::ostringstream out;
50 BOOST_CHECK_EQUAL(
"> 2\n> 15\n> ", out.str());
55 std::istringstream in(
"1 / 2\n10 / 2 / 2");
56 std::ostringstream out;
58 BOOST_CHECK_EQUAL(
"> 0.5\n> 2.5\n> ", out.str());
63 std::istringstream in(
" 1.5 * 2 + 3 / 1.5 - (10 - 3) + 2 * -1");
64 std::ostringstream out;
66 BOOST_CHECK_EQUAL(
"> -4\n> ", out.str());
71 std::istringstream in(
" var half = 1 / 2\nvar one=1.0\n one + half");
72 std::ostringstream out;
74 BOOST_CHECK_EQUAL(
"> 0.5\n> 1\n> 1.5\n> ", out.str());
79 std::istringstream in(
" pi - e");
80 std::ostringstream out;
82 BOOST_CHECK_EQUAL(
"> 0.423311\n> ", out.str());
87 std::istringstream in(
"1+++2");
88 std::ostringstream out;
90 BOOST_CHECK_EQUAL(
"> syntax error: expected a primary, but got +\n> ", out.str());
95 std::istringstream in(
"1..2");
96 std::ostringstream out;
98 BOOST_CHECK_EQUAL(
"> syntax error: expected digit after decimal point, got '.'\n> ", out.str());
103 std::istringstream in(
"1 @ 2");
104 std::ostringstream out;
106 BOOST_CHECK_EQUAL(
"> syntax error: expected digit, got '@'\n> ", out.str());
111 std::istringstream in(
"(1 + 2");
112 std::ostringstream out;
114 BOOST_CHECK_EQUAL(
"> syntax error: EOF when expecting ')'\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE(test_basics)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(node_test)