mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Tests: Added test for trivial but non-empty grammar
This commit is contained in:
parent
59e2b7911b
commit
18186de479
1 changed files with 14 additions and 2 deletions
|
@ -31,11 +31,10 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int, char**)
|
int main (int, char**)
|
||||||
{
|
{
|
||||||
UnitTest t (3);
|
UnitTest t (4);
|
||||||
|
|
||||||
// Test loading from a missing file.
|
// Test loading from a missing file.
|
||||||
Grammar g;
|
Grammar g;
|
||||||
|
|
||||||
File missing ("/tmp/does/not/exist");
|
File missing ("/tmp/does/not/exist");
|
||||||
t.ok (! missing.exists (), "Input file does not exist");
|
t.ok (! missing.exists (), "Input file does not exist");
|
||||||
try
|
try
|
||||||
|
@ -60,6 +59,19 @@ int main (int, char**)
|
||||||
t.diag (s);
|
t.diag (s);
|
||||||
t.pass ("Grammar::loadFromFile rejected an empty grammar");
|
t.pass ("Grammar::loadFromFile rejected an empty grammar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test error on non-empty but trivial grammar.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
g.loadFromString ("# Comment\n# comment\n\n\n\n");
|
||||||
|
t.fail ("Grammar::loadFromFile accepted an empty grammar");
|
||||||
|
}
|
||||||
|
catch (std::string s)
|
||||||
|
{
|
||||||
|
t.diag (s);
|
||||||
|
t.pass ("Grammar::loadFromFile rejected an empty grammar");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue