From fe2f5de2301bbeffc0ca0f4fa037d2c7adc5906f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 28 Dec 2014 10:04:20 -0500 Subject: [PATCH] Unit Tests - Added _neg_ unit tests for integer, real and duration. --- test/eval.t.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/eval.t.cpp b/test/eval.t.cpp index e0fa43849..9ef28d52d 100644 --- a/test/eval.t.cpp +++ b/test/eval.t.cpp @@ -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; }