Unit Tests

- Added _neg_ unit tests for integer, real and duration.
This commit is contained in:
Paul Beckingham 2014-12-28 10:04:20 -05:00
parent 0f780bcfae
commit fe2f5de230

View file

@ -46,7 +46,7 @@ bool get (const std::string& name, Variant& value)
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (46);
UnitTest t (52);
// Test the source independently.
Variant v;
@ -150,6 +150,19 @@ int main (int argc, char** argv)
t.is (result.type (), Variant::type_boolean, "infix '!true' --> boolean");
t.is (result.get_bool (), false, "infix '!true' --> false");
// _neg_
e.evaluateInfixExpression ("- 1", result);
t.is (result.type (), Variant::type_integer, "infix '- 1' --> integer");
t.is (result.get_integer (), -1, "infix '- 1' --> -1");
e.evaluateInfixExpression ("- 1.2", result);
t.is (result.type (), Variant::type_real, "infix '- 1.2' --> real");
t.is (result.get_real (), -1.2, "infix '- 1.2' --> -1.2");
e.evaluateInfixExpression ("- 2days", result);
t.is (result.type (), Variant::type_duration, "infix '- 2days' --> duration");
t.is (result.get_duration (), -86400*2, "infix '- 2days' --> -86400 * 2");
return 0;
}