mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Test: Added Lexer::decomposePair tests
This commit is contained in:
parent
81599071e7
commit
826c6986ae
1 changed files with 23 additions and 1 deletions
|
@ -36,7 +36,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (806);
|
||||
UnitTest t (1046);
|
||||
|
||||
std::vector <std::pair <std::string, Lexer::Type>> tokens;
|
||||
std::string token;
|
||||
|
@ -188,6 +188,28 @@ 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[7], "'c d'", "split ' +-* a+b 12.3e4 'c d'' -> [7] ''c d''");
|
||||
|
||||
// static bool decomposePair (const std::string&, std::string&, std::string&, std::string&, std::string&);
|
||||
// 2 * 4 * 2 * 5 = 80 tests.
|
||||
std::string outName, outMod, outValue, outSep;
|
||||
for (auto& name : {"name"})
|
||||
{
|
||||
for (auto& mod : {"", "mod"})
|
||||
{
|
||||
for (auto& sep : {":", "=", "::", ":="})
|
||||
{
|
||||
for (auto& value : {"", "value", "a:b", "a::b", "a=b", "a:=b"})
|
||||
{
|
||||
std::string input = std::string ("name") + (strlen (mod) ? "." : "") + mod + sep + value;
|
||||
t.ok (Lexer::decomposePair (input, outName, outMod, outValue, outSep), "decomposePair '" + input + "' --> true");
|
||||
t.is (name, outName, " '" + input + "' --> name '" + name + "'");
|
||||
t.is (mod, outMod, " '" + input + "' --> mod '" + mod + "'");
|
||||
t.is (value, outValue, " '" + input + "' --> value '" + value + "'");
|
||||
t.is (sep, outSep, " '" + input + "' --> sep '" + sep + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test all Lexer types.
|
||||
#define NO {"",Lexer::Type::word}
|
||||
struct
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue