From 8a5d7bb56955b8ad407373fd3df9a59ef1dc7b50 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 24 Apr 2014 09:08:19 -0400 Subject: [PATCH] Unit Tests - Added more Lexer::split tests. --- test/lexer.t.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/lexer.t.cpp b/test/lexer.t.cpp index bff4f2e87..fa398a070 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 (176); + UnitTest t (181); std::vector > tokens; std::string token; @@ -310,6 +310,15 @@ int main (int argc, char** argv) t.is (items[3], "B", "split ' ( A or B ) ' -> [3] 'B'"); t.is (items[4], ")", "split ' ( A or B ) ' -> [4] ')'"); + // Test simple mode with contrived tokens that ordinarily split. + unsplit = " +-* a+b 12.3e4 'c d'"; + Lexer::split (items, unsplit); + t.is (items.size (), (size_t) 4, "split ' +-* a+b 12.3e4 'c d''"); + t.is (items[0], "+-*", "split ' +-* a+b 12.3e4 'c d'' -> [0] '+-*'"); + t.is (items[1], "a+b", "split ' +-* a+b 12.3e4 'c d'' -> [1] 'a+b'"); + t.is (items[2], "12.3e4", "split ' +-* a+b 12.3e4 'c d'' -> [2] '12.3e4'"); + t.is (items[3], "c d", "split ' +-* a+b 12.3e4 'c d'' -> [3] 'c d'"); + return 0; }