mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Lexer
- Renamed ::split to ::word_split, for clarity and because of the need for a full token split, coming next.
This commit is contained in:
parent
e753473dc4
commit
0af9bbdc03
5 changed files with 18 additions and 18 deletions
|
@ -299,25 +299,25 @@ int main (int argc, char** argv)
|
|||
t.is (tokens[20].first, ")", "tokens[20] == ')'");
|
||||
t.is (tokens[20].second, Lexer::typeOperator, "tokens[20] == typeOperator"); // 170
|
||||
|
||||
// void splitq (std::vector<std::string>&, const std::string&);
|
||||
// void word_split (std::vector<std::string>&, const std::string&);
|
||||
std::string unsplit = " ( A or B ) ";
|
||||
std::vector <std::string> items;
|
||||
Lexer::split (items, unsplit);
|
||||
t.is (items.size (), (size_t) 5, "split ' ( A or B ) '");
|
||||
t.is (items[0], "(", "split ' ( A or B ) ' -> [0] '('");
|
||||
t.is (items[1], "A", "split ' ( A or B ) ' -> [1] 'A'");
|
||||
t.is (items[2], "or", "split ' ( A or B ) ' -> [2] 'or'");
|
||||
t.is (items[3], "B", "split ' ( A or B ) ' -> [3] 'B'");
|
||||
t.is (items[4], ")", "split ' ( A or B ) ' -> [4] ')'");
|
||||
Lexer::word_split (items, unsplit);
|
||||
t.is (items.size (), (size_t) 5, "word_split ' ( A or B ) '");
|
||||
t.is (items[0], "(", "word_split ' ( A or B ) ' -> [0] '('");
|
||||
t.is (items[1], "A", "word_split ' ( A or B ) ' -> [1] 'A'");
|
||||
t.is (items[2], "or", "word_split ' ( A or B ) ' -> [2] 'or'");
|
||||
t.is (items[3], "B", "word_split ' ( A or B ) ' -> [3] 'B'");
|
||||
t.is (items[4], ")", "word_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'");
|
||||
Lexer::word_split (items, unsplit);
|
||||
t.is (items.size (), (size_t) 4, "word_split ' +-* a+b 12.3e4 'c d''");
|
||||
t.is (items[0], "+-*", "word_split ' +-* a+b 12.3e4 'c d'' -> [0] '+-*'");
|
||||
t.is (items[1], "a+b", "word_split ' +-* a+b 12.3e4 'c d'' -> [1] 'a+b'");
|
||||
t.is (items[2], "12.3e4", "word_split ' +-* a+b 12.3e4 'c d'' -> [2] '12.3e4'");
|
||||
t.is (items[3], "c d", "word_split ' +-* a+b 12.3e4 'c d'' -> [3] 'c d'");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue