Skip to content

Commit

Permalink
Fix the broken unit test
Browse files Browse the repository at this point in the history
At the very least, this should allow it to compile...
  • Loading branch information
CelticMinstrel committed Mar 17, 2017
1 parent dff4b78 commit e5f92fe
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/tests/test_formula_core.cpp
Expand Up @@ -175,25 +175,24 @@ BOOST_AUTO_TEST_CASE(test_formula_containers) {

BOOST_AUTO_TEST_CASE(test_formula_tokenizer) {
using namespace formula_tokenizer;
std::string test = "(abc + 4 * (5+3))^2";
std::string test = "[(abc + 4 * (5+3))^2.0, functions, '[']thing[']']";
std::string::const_iterator i1 = test.begin();
std::string::const_iterator i2 = test.end();
TOKEN_TYPE types[] = {TOKEN_LPARENS, TOKEN_IDENTIFIER,
TOKEN_WHITESPACE, TOKEN_OPERATOR,
TOKEN_WHITESPACE, TOKEN_INTEGER,
TOKEN_WHITESPACE, TOKEN_OPERATOR,
TOKEN_WHITESPACE, TOKEN_LPARENS,
TOKEN_INTEGER, TOKEN_OPERATOR,
TOKEN_INTEGER, TOKEN_RPARENS,
TOKEN_RPARENS, TOKEN_KEYWORD,
TOKEN_OPERATOR, TOKEN_INTEGER};
std::string tokens[] = {"(", "abc", " ", "+", " ", "4", " ",
"*", " ", "(", "5", "+", "3", ")", ")", "functions"};
for(std::string tok : tokens) {
std::pair<std::string, TOKEN_TYPE> tokens[] = {
{"[", TOKEN_LSQUARE}, {"(", TOKEN_LPARENS}, {"abc", TOKEN_IDENTIFIER},
{" ", TOKEN_WHITESPACE}, {"+", TOKEN_OPERATOR}, {" ", TOKEN_WHITESPACE},
{"4", TOKEN_INTEGER}, {" ", TOKEN_WHITESPACE}, {"*", TOKEN_OPERATOR},
{" ", TOKEN_WHITESPACE}, {"(", TOKEN_LPARENS}, {"5", TOKEN_INTEGER},
{"+", TOKEN_OPERATOR}, {"3", TOKEN_INTEGER}, {")", TOKEN_RPARENS},
{")", TOKEN_RPARENS}, {"^", TOKEN_OPERATOR}, {"2.0", TOKEN_DECIMAL},
{",", TOKEN_COMMA}, {" ", TOKEN_WHITESPACE}, {"functions", TOKEN_KEYWORD},
{",", TOKEN_COMMA}, {" ", TOKEN_WHITESPACE}, {"'[']thing[']'", TOKEN_STRING_LITERAL},
{"]", TOKEN_RSQUARE},
};
for(auto tok : tokens) {
token t = get_token(i1, i2);
assert(std::string(t.begin, t.end) == tokens[n]);
assert(t.type == types[n]);

assert(std::string(t.begin, t.end) == tok.first);
assert(t.type == tok.second);
}
return 0;
}
Expand Down

0 comments on commit e5f92fe

Please sign in to comment.