mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tests: Added Lexer::Type::operator tests, removed old ones
This commit is contained in:
parent
9adf3fc0fa
commit
fee58b0eb6
1 changed files with 5 additions and 25 deletions
|
@ -36,7 +36,7 @@ Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (628);
|
UnitTest t (634);
|
||||||
|
|
||||||
std::vector <std::pair <std::string, Lexer::Type> > tokens;
|
std::vector <std::pair <std::string, Lexer::Type> > tokens;
|
||||||
std::string token;
|
std::string token;
|
||||||
|
@ -369,29 +369,6 @@ int main (int argc, char** argv)
|
||||||
t.is (items[6], "12.3e4", "split ' +-* a+b 12.3e4 'c d'' -> [6] '12.3e4'");
|
t.is (items[6], "12.3e4", "split ' +-* a+b 12.3e4 'c d'' -> [6] '12.3e4'");
|
||||||
t.is (items[7], "'c d'", "split ' +-* a+b 12.3e4 'c d'' -> [7] ''c d''");
|
t.is (items[7], "'c d'", "split ' +-* a+b 12.3e4 'c d'' -> [7] ''c d''");
|
||||||
|
|
||||||
// Test common expression element.
|
|
||||||
unsplit = "name=value";
|
|
||||||
items = Lexer::split (unsplit);
|
|
||||||
t.is (items.size (), (size_t) 3, "split 'name=value'");
|
|
||||||
if (items.size () == 3)
|
|
||||||
{
|
|
||||||
t.is (items[0], "name", "split 'name=value' -> [0] 'name'");
|
|
||||||
t.is (items[1], "=", "split 'name=value' -> [1] '='");
|
|
||||||
t.is (items[2], "value", "split 'name=value' -> [2] 'value'");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t.fail ("split 'name=value' -> [0] 'name'");
|
|
||||||
t.fail ("split 'name=value' -> [1] '='");
|
|
||||||
t.fail ("split 'name=value' -> [2] 'value'");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test unterminated tokens.
|
|
||||||
unsplit = " ordinary ";
|
|
||||||
items = Lexer::split (unsplit);
|
|
||||||
t.is (items.size (), (size_t) 1, "split 'ordinary' --> 1 token");
|
|
||||||
t.is (items[0], "ordinary", "split 'ordinary' --> 'ordinary'");
|
|
||||||
|
|
||||||
// Test all Lexer types.
|
// Test all Lexer types.
|
||||||
#define NO {"",Lexer::Type::word}
|
#define NO {"",Lexer::Type::word}
|
||||||
struct
|
struct
|
||||||
|
@ -455,6 +432,7 @@ int main (int argc, char** argv)
|
||||||
{ "desc.cont:pattern", { { "desc.cont:pattern", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
{ "desc.cont:pattern", { { "desc.cont:pattern", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
||||||
{ "pro:'P 1'", { { "pro:'P 1'", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
{ "pro:'P 1'", { { "pro:'P 1'", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
||||||
{ "pro:PROJECT", { { "pro:PROJECT", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
{ "pro:PROJECT", { { "pro:PROJECT", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
||||||
|
{ "due:'eow - 2d'", { { "due:'eow - 2d'", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
||||||
|
|
||||||
// RC override
|
// RC override
|
||||||
{ "rc:x", { { "rc:x", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
{ "rc:x", { { "rc:x", Lexer::Type::pair }, NO, NO, NO, NO }, },
|
||||||
|
@ -467,6 +445,9 @@ int main (int argc, char** argv)
|
||||||
{ "xor", { { "xor", Lexer::Type::op }, NO, NO, NO, NO }, },
|
{ "xor", { { "xor", Lexer::Type::op }, NO, NO, NO, NO }, },
|
||||||
{ "_hastag_", { { "_hastag_", Lexer::Type::op }, NO, NO, NO, NO }, },
|
{ "_hastag_", { { "_hastag_", Lexer::Type::op }, NO, NO, NO, NO }, },
|
||||||
|
|
||||||
|
// Word that starts wih 'or', which is an operator, but should be ignored.
|
||||||
|
{ "ordinary", { { "ordinary", Lexer::Type::dom }, NO, NO, NO, NO }, },
|
||||||
|
|
||||||
// UUID
|
// UUID
|
||||||
{ "a360fc44-315c-4366-b70c-ea7e7520b749", { { "a360fc44-315c-4366-b70c-ea7e7520b749", Lexer::Type::uuid }, NO, NO, NO, NO }, },
|
{ "a360fc44-315c-4366-b70c-ea7e7520b749", { { "a360fc44-315c-4366-b70c-ea7e7520b749", Lexer::Type::uuid }, NO, NO, NO, NO }, },
|
||||||
{ "a360fc44-315c-4366-b70c-ea7e752", { { "a360fc44-315c-4366-b70c-ea7e752", Lexer::Type::uuid }, NO, NO, NO, NO }, },
|
{ "a360fc44-315c-4366-b70c-ea7e752", { { "a360fc44-315c-4366-b70c-ea7e752", Lexer::Type::uuid }, NO, NO, NO, NO }, },
|
||||||
|
@ -497,7 +478,6 @@ int main (int argc, char** argv)
|
||||||
// 4,5-6
|
// 4,5-6
|
||||||
|
|
||||||
// Expression
|
// Expression
|
||||||
// due:'eow - 2d'
|
|
||||||
// due:eom-2w
|
// due:eom-2w
|
||||||
// due < eom + 1w + 1d
|
// due < eom + 1w + 1d
|
||||||
// ( /pattern/ or 8ad2e3db-914d-4832-b0e6-72fa04f6e331,3b6218f9-726a-44fc-aa63-889ff52be442 )
|
// ( /pattern/ or 8ad2e3db-914d-4832-b0e6-72fa04f6e331,3b6218f9-726a-44fc-aa63-889ff52be442 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue