← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20362: Test

 

------------------------------------------------------------
revno: 20362
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-09-25 14:38:13 +0200
message:
  Test
modified:
  dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/ExpressionUtilsTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/ExpressionUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/ExpressionUtilsTest.java	2015-09-25 12:29:08 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/test/java/org/hisp/dhis/commons/util/ExpressionUtilsTest.java	2015-09-25 12:38:13 +0000
@@ -81,10 +81,24 @@
         assertEquals( 4d, ExpressionUtils.evaluateToDouble( "d2:zing(v1) + d2:zing(v2)", vars ), DELTA );
     }
     
-    //@Test
+    @Test
     public void testEvaluateToDoubleZeroPositiveValueCount()
     {
-        String expression = "d2:zing(3";
+        String expression = "d2:zpvc(2,3,-1,0)";
+        
+        assertEquals( 3d, ExpressionUtils.evaluateToDouble( expression, null ), DELTA );
+        
+        expression  = "(d2:zing(4) + d2:zing(0) + d2:zing(-1)) / d2:zpvc(2,0,-1)";
+
+        assertEquals( 2d, ExpressionUtils.evaluateToDouble( expression, null ), DELTA );
+
+        expression  = 
+            "((d2:zing(4) + d2:zing(0) + d2:zing(-1)) / d2:zpvc(2,0,-1) * 0.25) + " +
+            "((d2:zing(8) + d2:zing(0) + d2:zing(-1)) / d2:zpvc(2,0,-1) * 0.75)";
+
+        assertEquals( 3.5, ExpressionUtils.evaluateToDouble( expression, null ), DELTA );
+        
+        
     }
 
     @Test