mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tests: Added more Lexer::Type::dom tests
This commit is contained in:
parent
b02d518b02
commit
0eaa061efe
1 changed files with 23 additions and 17 deletions
|
@ -36,7 +36,7 @@ Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
UnitTest t (304);
|
UnitTest t (334);
|
||||||
|
|
||||||
std::vector <std::pair <std::string, Lexer::Type> > tokens;
|
std::vector <std::pair <std::string, Lexer::Type> > tokens;
|
||||||
std::string token;
|
std::string token;
|
||||||
|
@ -393,7 +393,7 @@ int main (int argc, char** argv)
|
||||||
t.is (items[0], "ordinary", "split 'ordinary' --> 'ordinary'");
|
t.is (items[0], "ordinary", "split 'ordinary' --> 'ordinary'");
|
||||||
|
|
||||||
// Test all Lexer types.
|
// Test all Lexer types.
|
||||||
#define NOPE {"",Lexer::Type::word}
|
#define NO {"",Lexer::Type::word}
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const char* input;
|
const char* input;
|
||||||
|
@ -404,21 +404,27 @@ int main (int argc, char** argv)
|
||||||
} results[3];
|
} results[3];
|
||||||
} lexerTests[] =
|
} lexerTests[] =
|
||||||
{
|
{
|
||||||
{ "/foo/", { { "/foo/", Lexer::Type::pattern }, NOPE, NOPE }, },
|
{ "/foo/", { { "/foo/", Lexer::Type::pattern }, NO, NO }, },
|
||||||
{ "/a\\/b/", { { "/a\\/b/", Lexer::Type::pattern }, NOPE, NOPE }, },
|
{ "/a\\/b/", { { "/a\\/b/", Lexer::Type::pattern }, NO, NO }, },
|
||||||
{ "/'/", { { "/'/", Lexer::Type::pattern }, NOPE, NOPE }, },
|
{ "/'/", { { "/'/", Lexer::Type::pattern }, NO, NO }, },
|
||||||
{ "desc~pattern", { { "desc", Lexer::Type::dom },
|
{ "desc~pattern", { { "desc", Lexer::Type::dom },
|
||||||
{ "~", Lexer::Type::op },
|
{ "~", Lexer::Type::op },
|
||||||
{ "pattern", Lexer::Type::dom }, }, },
|
{ "pattern", Lexer::Type::dom }, }, },
|
||||||
{ "desc.cont:pattern", { { "desc.cont:pattern", Lexer::Type::pair }, NOPE, NOPE }, },
|
{ "desc.cont:pattern", { { "desc.cont:pattern", Lexer::Type::pair }, NO, NO }, },
|
||||||
{ "/from/to/g", { { "/from/to/g", Lexer::Type::substitution }, NOPE, NOPE }, },
|
{ "/from/to/g", { { "/from/to/g", Lexer::Type::substitution }, NO, NO }, },
|
||||||
{ "/from/to/", { { "/from/to/", Lexer::Type::substitution }, NOPE, NOPE }, },
|
{ "/from/to/", { { "/from/to/", Lexer::Type::substitution }, NO, NO }, },
|
||||||
{ "+tag", { { "+tag", Lexer::Type::tag }, NOPE, NOPE }, },
|
{ "+tag", { { "+tag", Lexer::Type::tag }, NO, NO }, },
|
||||||
{ "-tag", { { "-tag", Lexer::Type::tag }, NOPE, NOPE }, },
|
{ "-tag", { { "-tag", Lexer::Type::tag }, NO, NO }, },
|
||||||
{ "foo", { { "foo", Lexer::Type::dom }, NOPE, NOPE }, },
|
{ "foo", { { "foo", Lexer::Type::dom }, NO, NO }, },
|
||||||
{ "/long/path/to/file.txt", { { "/long/path/to/file.txt", Lexer::Type::path }, NOPE, NOPE }, },
|
{ "/long/path/to/file.txt", { { "/long/path/to/file.txt", Lexer::Type::path }, NO, NO }, },
|
||||||
{ "Çirçös", { { "Çirçös", Lexer::Type::dom }, NOPE, NOPE }, },
|
{ "Çirçös", { { "Çirçös", Lexer::Type::dom }, NO, NO }, },
|
||||||
{ "☺", { { "☺", Lexer::Type::dom }, NOPE, NOPE }, },
|
{ "☺", { { "☺", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
{ "name", { { "name", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
{ "f1", { { "f1", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
{ "foo.bar", { { "foo.bar", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
{ "1.foo.bar", { { "1.foo.bar", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
{ "a360fc44-315c-4366-b70c-ea7e7520b749.foo.bar", { { "a360fc44-315c-4366-b70c-ea7e7520b749.foo.bar", Lexer::Type::dom }, NO, NO }, },
|
||||||
|
|
||||||
};
|
};
|
||||||
#define NUM_TESTS (sizeof (lexerTests) / sizeof (lexerTests[0]))
|
#define NUM_TESTS (sizeof (lexerTests) / sizeof (lexerTests[0]))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue