From e5f92fef08ede9680a5fdcadbf28f738112d9628 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Thu, 16 Mar 2017 21:43:19 -0400 Subject: [PATCH] Fix the broken unit test At the very least, this should allow it to compile... --- src/tests/test_formula_core.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/tests/test_formula_core.cpp b/src/tests/test_formula_core.cpp index 84127d99e61c..e32e22bf7b17 100644 --- a/src/tests/test_formula_core.cpp +++ b/src/tests/test_formula_core.cpp @@ -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 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; }