From 0aa323164a56cd746333fa271c15a1fce9006b65 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 8 Jun 2014 14:16:46 -0400 Subject: [PATCH] Unit Tests - Added Lexer tests to make sure '9th' and '10th' are recognized as identifiers. --- test/lexer.t.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/lexer.t.cpp b/test/lexer.t.cpp index 7bdf404b0..4cdd05f6b 100644 --- a/test/lexer.t.cpp +++ b/test/lexer.t.cpp @@ -36,7 +36,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (185); + UnitTest t (190); std::vector > tokens; std::string token; @@ -299,6 +299,22 @@ int main (int argc, char** argv) t.is (tokens[20].first, ")", "tokens[20] == ')'"); t.is (tokens[20].second, Lexer::typeOperator, "tokens[20] == typeOperator"); // 170 + // Test ordinal dates. + Lexer l8 ("9th 10th"); + l8.ambiguity (false); + tokens.clear (); + while (l8.token (token, type)) + { + std::cout << "# «" << token << "» " << type << " " << Lexer::type_name (type) << "\n"; + tokens.push_back (std::pair (token, type)); + } + + t.is ((int)tokens.size (), 2, "2 tokens"); + t.is (tokens[0].first, "9th", "tokens[0] == '9th'"); + t.is (tokens[0].second, Lexer::typeIdentifier, "tokens[0] == typeIdentifier"); + t.is (tokens[1].first, "10th", "tokens[1] == '10th'"); + t.is (tokens[1].second, Lexer::typeIdentifier, "tokens[1] == typeIdentifier"); + // void word_split (std::vector&, const std::string&); std::string unsplit = " ( A or B ) "; std::vector items;