Skip to content

Commit

Permalink
Remove duplicate tests for aggregate functions, aggregate queries, an…
Browse files Browse the repository at this point in the history
…d arithmetic functions (#1396)

* Remove duplicate aggregate function tests

* Remove duplicate aggregate query tests

* Remove duplicate arithmetic function tests

---------

Co-authored-by: JP <[email protected]>
  • Loading branch information
antvaset and JPercival authored Aug 1, 2024
1 parent 7e91478 commit f06fabe
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 1,406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<expression>AllTrue({})</expression>
<output>true</output>
</test>
<test name="AllTrueIsTrueWhenNull">
<expression>AllTrue(null)</expression>
<output>true</output>
</test>
</group>
<group name="AnyTrue">
<test name="AnyTrueAllTrue">
Expand Down Expand Up @@ -68,13 +72,23 @@
<expression>AnyTrue({})</expression>
<output>false</output>
</test>
<test name="AnyTrueIsFalseWhenNull">
<expression>AnyTrue(null)</expression>
<output>false</output>
</test>
</group>
<group name="Avg">
<test name="AvgTest1">
<expression>Avg({ 1.0, 2.0, 3.0, 6.0 })</expression>
<output>3.0</output>
</test>
</group>
<group name="Product">
<test name="Product_Long">
<expression>Product({5L, 4L, 5L})</expression>
<output>100L</output>
</test>
</group>
<group name="Count">
<test name="CountTest1">
<expression>Count({ 15, 5, 99, null, 1 })</expression>
Expand All @@ -98,6 +112,10 @@
<expression>Max({ 5, 12, 1, 15, 0, 4, 90, 44 })</expression>
<output>90</output>
</test>
<test name="MaxTestLong">
<expression>Max({ 5L, 12L, 1L, 15L, 0L, 4L, 90L, 44L })</expression>
<output>90L</output>
</test>
<test name="MaxTestString">
<expression>Max({ 'hi', 'bye', 'zebra' })</expression>
<output>'zebra'</output>
Expand All @@ -122,6 +140,10 @@
<expression>Min({5, 12, 1, 15, 0, 4, 90, 44})</expression>
<output>0</output>
</test>
<test name="MinTestLong">
<expression>Min({5L, 12L, 1L, 15L, 0L, 4L, 90L, 44L})</expression>
<output>0L</output>
</test>
<test name="MinTestString">
<expression>Min({'hi', 'bye', 'zebra'})</expression>
<output>'bye'</output>
Expand All @@ -144,6 +166,10 @@
<expression>Mode({ DateTime(2012, 10, 5), DateTime(2012, 9, 5), DateTime(2012, 10, 6), DateTime(2012, 9, 5) })</expression>
<output>DateTime(2012, 9, 5)</output>
</test>
<test name="ModeTestDateTime2">
<expression>Mode({ DateTime(2012, 10, 5), DateTime(2012, 10, 5), DateTime(2012, 10, 6), DateTime(2012, 9, 5) })</expression>
<output>DateTime(2012, 10, 5)</output>
</test>
<test name="ModeTestTime">
<expression>Mode({ @T15:59:59.999, @T05:59:59.999, @T20:59:59.999, @T05:59:59.999 })</expression>
<output>@T05:59:59.999</output>
Expand All @@ -155,25 +181,45 @@
<output>1.41421356</output>
<!-- 23730951454746218587388284504413604736328125 -->
</test>
<test name="PopulationStdDevIsNull">
<expression>PopulationStdDev({ null as Quantity, null as Quantity, null as Quantity })</expression>
<output>null</output>
</test>
</group>
<group name="PopulationVariance">
<test name="PopVarianceTest1">
<expression>PopulationVariance({ 1.0, 2.0, 3.0, 4.0, 5.0 })</expression>
<output>2.0</output>
</test>
<test name="PopVarianceIsNull">
<expression>PopulationVariance({ null as Quantity, null as Quantity, null as Quantity })</expression>
<output>null</output>
</test>
</group>
<group name="StdDev">
<test name="StdDevTest1">
<expression>StdDev({ 1.0, 2.0, 3.0, 4.0, 5.0 })</expression>
<output>1.58113883</output>
<!-- 00841897613935316257993690669536590576171875 -->
</test>
<test name="StdDevIsNull">
<expression>StdDev({ null as Quantity, null as Quantity, null as Quantity })</expression>
<output>null</output>
</test>
</group>
<group name="Sum">
<test name="SumTest1">
<expression>Sum({ 6.0, 2.0, 3.0, 4.0, 5.0 })</expression>
<output>20.0</output>
</test>
<test name="SumTestLong">
<expression>Sum({ 6L, 2L, 3L, 4L, 5L })</expression>
<output>20L</output>
</test>
<test name="SumTestQuantity">
<expression>Sum({1 'ml',2 'ml',3 'ml',4 'ml',5 'ml'})</expression>
<output>15 'ml'</output>
</test>
<test name="SumTestNull">
<expression>Sum({ null, 1, null })</expression>
<output>1</output>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://hl7.org/fhirpath/tests" xsi:schemaLocation="http://hl7.org/fhirpath/tests ../../testSchema/testSchema.xsd"
name="CqlAggregateTest" reference="http://build.fhir.org/ig/HL7/cql/03-developersguide.html#aggregate-queries">
name="CqlAggregateTest" reference="http://build.fhir.org/ig/HL7/cql/03-developersguide.html#aggregate-queries">
<group name="AggregateTests">
<test name="FactorialOfFive">
<expression>({ 1, 2, 3, 4, 5 }) Num aggregate Result starting 1: Result * Num</expression>
<output>120</output>
</test>
<test name="RolledOutIntervals">
<expression>({
Interval[@2012-01-01, @2012-02-28],
Interval[@2012-02-01, @2012-03-31],
Interval[@2012-03-01, @2012-04-30]
}) M
aggregate R starting (null as List&lt;Interval&lt;DateTime>>): R union ({
M X
let S: Max({ end of Last(R) + 1 day, start of X }),
E: S + duration in days of X
return Interval[S, E]
})</expression>
<output>{
Interval[@2012-01-01, @2012-02-28],
Interval[@2012-02-29, @2012-04-28],
Interval[@2012-04-29, @2012-06-28]
}</output>
<!-- Execution Error: Invalid precision: 1. -->
</test>
</group>
<test name="RolledOutIntervals">
<expression>
({
Interval[@2012-01-01, @2012-02-28],
Interval[@2012-02-01, @2012-03-31],
Interval[@2012-03-01, @2012-04-30]
}) M
aggregate R starting (null as List&lt;Interval&lt;DateTime>>): R union ({
M X
let S: Max({ end of Last(R) + 1 day, start of X }),
E: S + duration in days of X
return Interval[S, E]
})
</expression>
<output>
{
Interval[@2012-01-01, @2012-02-28],
Interval[@2012-02-29, @2012-04-28],
Interval[@2012-04-29, @2012-06-28]
}
</output>
<!-- Execution Error: Invalid precision: 1. -->
</test>
<test name="AggregateSumWithStart">
<expression>
({ 1, 2, 3, 4, 5 }) Num
aggregate Result starting 1: Result + Num
</expression>
<output>16</output>
<!-- 15 + 1 (the initial value) -->
</test>
<test name="AggregateSumWithNull">
<expression>
({ 1, 2, 3, 4, 5 }) Num
aggregate Result: Coalesce(Result, 0) + Num
</expression>
<output>15</output>
<!-- 15 + 0 (the initial value from null) -->
</test>
<test name="AggregateSumAll">
<expression>
({ 1, 1, 2, 2, 2, 3, 4, 4, 5 }) Num
aggregate all Result: Coalesce(Result, 0) + Num
</expression>
<output>24</output>
<!-- 24 + 0 -->
</test>
<test name="AggregateSumDistinct">
<expression>
({ 1, 1, 2, 2, 2, 3, 4, 4, 5 }) Num
aggregate distinct Result: Coalesce(Result, 0) + Num
</expression>
<output>15</output>
<!-- 15 + 0 (the initial value) -->
</test>
<test name="Multi">
<expression>
from ({1}) X, ({2}) Y, ({3}) Z
aggregate Agg: Coalesce(Agg, 0) + X + Y + Z
</expression>
<output>6</output>
</test>
<test name="MegaMulti">
<expression>
from ({1, 2}) X, ({1, 2}) Y, ({1, 2}) Z
aggregate Agg starting 0: Agg + X + Y + Z
</expression>
<output>36</output>
<!-- (1+1+1)+(1+1+2)+(1+2+1)+(1+2+2)+(2+1+1)+(2+1+2)+(2+2+1)+(2+2+2) -->
</test>
<test name="MegaMultiDistinct">
<expression>
from ({1, 2, 2, 1}) X, ({1, 2, 1, 2}) Y, ({2, 1, 2, 1}) Z
aggregate distinct Agg starting 1: Agg + X + Y + Z
</expression>
<output>37</output>
<!-- 1 + (1+1+1)+(1+1+2)+(1+2+1)+(1+2+2)+(2+1+1)+(2+1+2)+(2+2+1)+(2+2+2) -->
</test>
</group>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<expression>1 + 1</expression>
<output>2</output>
</test>
<test name="Add1L2L">
<expression>1L + 2L</expression>
<output>3L</output>
</test>
<test name="Add1D1D">
<expression>1.0 + 1.0</expression>
<output>2.0</output>
Expand Down Expand Up @@ -104,6 +108,10 @@
<expression>1 / 1</expression>
<output>1.0</output>
</test>
<test name="Divide1L1L">
<expression>1L / 1L</expression>
<output>1.0</output>
</test>
<test name="Divide1d1d">
<expression>1.0 / 1.0</expression>
<output>1.0</output>
Expand Down Expand Up @@ -195,6 +203,10 @@
<expression>Round(Exp(1), 8)</expression>
<output>2.71828183</output>
</test>
<test name="Exp1L">
<expression>Round(Exp(1L), 8)</expression>
<output>2.71828183</output>
</test>
<test name="ExpNeg1">
<expression>Round(Exp(-1), 8)</expression>
<output>0.36787944</output>
Expand Down Expand Up @@ -225,6 +237,14 @@
<expression>HighBoundary(@T10:30, 9)</expression>
<output>@T10:30:59.999</output>
</test>
<test name="HighBoundaryNull">
<expression>HighBoundary(null as Decimal, 8)</expression>
<output>null</output>
</test>
<test name="HighBoundaryNullPrecision">
<expression>HighBoundary(1.58888, null)</expression>
<output>1.58888999</output>
</test>
</group>
<group name="Log">
<test name="LogNullNull">
Expand All @@ -251,6 +271,10 @@
<expression>Log(1, 100)</expression>
<output>0.0</output>
</test>
<test name="Log1Base100L">
<expression>Log(1L, 100L)</expression>
<output>0.0</output>
</test>
<test name="Log16Base2">
<expression>Log(16, 2)</expression>
<output>4.0</output>
Expand All @@ -277,6 +301,14 @@
<expression>LowBoundary(@T10:30, 9)</expression>
<output>@T10:30:00.000</output>
</test>
<test name="LowBoundaryNull">
<expression>LowBoundary(null as Decimal, 8)</expression>
<output>null</output>
</test>
<test name="LowBoundaryNullPrecision">
<expression>LowBoundary(1.58888, null)</expression>
<output>1.58888000</output>
</test>
</group>
<group name="Ln">
<test name="LnNull">
Expand All @@ -295,6 +327,10 @@
<expression>Ln(1)</expression>
<output>0.0</output>
</test>
<test name="Ln1L">
<expression>Ln(1L)</expression>
<output>0.0</output>
</test>
<test name="LnNeg1">
<expression>Ln(-1)</expression>
<output>null</output>
Expand Down Expand Up @@ -404,6 +440,14 @@
<expression>3.5 'cm' mod 3 'cm'</expression>
<output>0.5 'cm'</output>
</test>
<test name="Modulo10By3Quantity">
<expression>10.0 'g' mod 3.0 'g'</expression>
<output>1.0 'g'</output>
</test>
<test name="Modulo10By0Quantity">
<expression>10.0 'g' mod 0.0 'g'</expression>
<output>null</output>
</test>
</group>
<group name="Multiply">
<test name="MultiplyNull">
Expand All @@ -414,6 +458,10 @@
<expression>1 * 1</expression>
<output>1</output>
</test>
<test name="Multiply2LBy3L">
<expression>2L * 3L</expression>
<output>6L</output>
</test>
<test name="Multiply1DBy2D">
<expression>1.0 * 2.0</expression>
<output>2.0</output>
Expand Down Expand Up @@ -449,6 +497,14 @@
<expression>-1</expression>
<output>-1</output>
</test>
<test name="Negate1L">
<expression>-1L</expression>
<output>-1L</output>
</test>
<test name="NegateMaxLong">
<expression>-9223372036854775807L</expression>
<output>-9223372036854775807L</output>
</test>
<test name="NegateNeg1">
<expression>-(-1)</expression>
<output>1</output>
Expand Down Expand Up @@ -595,6 +651,10 @@
<expression>2^4</expression>
<output>16</output>
</test>
<test name="Power2LTo3L">
<expression>2L^3L</expression>
<output>8L</output>
</test>
<test name="Power2DTo4D">
<expression>2.0^4.0</expression>
<output>16.0</output>
Expand Down Expand Up @@ -833,5 +893,17 @@
<expression>10.1 'cm' div -3.1 'cm'</expression>
<output>-3.0 'cm'</output>
</test>
<test name="TruncatedDivide10By5DQuantity">
<expression>10.0 'g' div 5.0 'g'</expression>
<output>2.0 'g'</output>
</test>
<test name="TruncatedDivide414By206DQuantity">
<expression>4.14 'm' div 2.06 'm'</expression>
<output>2.0 'm'</output>
</test>
<test name="TruncatedDivide10By0DQuantity">
<expression>10.0 'g' div 0.0 'g'</expression>
<output>null</output>
</test>
</group>
</tests>
Loading

0 comments on commit f06fabe

Please sign in to comment.