#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>
#include <boost/test/auto_unit_test.hpp>
#include "parse.hpp"
Go to the source code of this file.
BOOST_AUTO_TEST_CASE |
( |
test_number |
| ) |
|
Definition at line 11 of file test_parse.cpp.
References parse_loop().
13 std::istringstream in{
"1\n3.14159\n1.23e45\n45.67e+8\n"};
14 std::ostringstream out{};
16 BOOST_CHECK_EQUAL(
"> 1\n> 3.14159\n> 1.23e+45\n> 4.567e+09\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_negative |
| ) |
|
Definition at line 19 of file test_parse.cpp.
References parse_loop().
21 std::istringstream in{
"-1\n-3.14159\n-1.23e-45\n-34.56e-7\n"};
22 std::ostringstream out{};
24 BOOST_CHECK_EQUAL(
"> -1\n> -3.14159\n> -1.23e-45\n> -3.456e-06\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_add |
| ) |
|
Definition at line 27 of file test_parse.cpp.
References parse_loop().
29 std::istringstream in{
"1 + 2\n1 + 2 + 3"};
30 std::ostringstream out{};
32 BOOST_CHECK_EQUAL(
"> 3\n> 6\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_subtract |
| ) |
|
Definition at line 35 of file test_parse.cpp.
References parse_loop().
37 std::istringstream in{
"1 - 2\n5 - 1 - 2"};
38 std::ostringstream out{};
40 BOOST_CHECK_EQUAL(
"> -1\n> 2\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_multiply |
| ) |
|
Definition at line 43 of file test_parse.cpp.
References parse_loop().
45 std::istringstream in{
"1 * 2\n5 * 2 * 1.5"};
46 std::ostringstream out{};
48 BOOST_CHECK_EQUAL(
"> 2\n> 15\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_divide |
| ) |
|
Definition at line 51 of file test_parse.cpp.
References parse_loop().
53 std::istringstream in{
"1 / 2\n10 / 2 / 2"};
54 std::ostringstream out{};
56 BOOST_CHECK_EQUAL(
"> 0.5\n> 2.5\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_mix |
| ) |
|
Definition at line 59 of file test_parse.cpp.
References parse_loop().
61 std::istringstream in{
" 1.5 * 2 + 3 / 1.5 - (10 - 3) + 2 * -1"};
62 std::ostringstream out{};
64 BOOST_CHECK_EQUAL(
"> -4\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_error1 |
| ) |
|
Definition at line 67 of file test_parse.cpp.
References parse_loop().
69 std::istringstream in{
"1+++2"};
70 std::ostringstream out{};
72 BOOST_CHECK_EQUAL(
"> syntax error: expected digit, got '+'\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_error2 |
| ) |
|
Definition at line 75 of file test_parse.cpp.
References parse_loop().
77 std::istringstream in{
"1..2"};
78 std::ostringstream out{};
80 BOOST_CHECK_EQUAL(
"> syntax error: expected digit after decimal point, got '.'\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_error3 |
| ) |
|
Definition at line 83 of file test_parse.cpp.
References parse_loop().
85 std::istringstream in{
"1 @ 2"};
86 std::ostringstream out{};
88 BOOST_CHECK_EQUAL(
"> 1\nsyntax error: expected digit, got '@'\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)
BOOST_AUTO_TEST_CASE |
( |
test_error4 |
| ) |
|
Definition at line 91 of file test_parse.cpp.
References parse_loop().
93 std::istringstream in{
"(1 + 2"};
94 std::ostringstream out{};
96 BOOST_CHECK_EQUAL(
"> syntax error: EOF when expecting ')'\n> ", out.str());
void parse_loop(std::istream &input, std::ostream &output)