Skip to content

Commit

Permalink
Fix type conversion operator tests for malformed inputs. Enable tests…
Browse files Browse the repository at this point in the history
… for Boolean and null literals. (#1371)

* Fix explicit conversion operator tests for malformed string inputs

* Enable Boolean and null literal tests

---------

Co-authored-by: JP <jonathan.i.percival@gmail.com>
  • Loading branch information
antvaset and JPercival authored Jul 3, 2024
1 parent 82b3584 commit ee6d3d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,19 @@ public static Object[][] dataMethod() {
"cql/CqlStringOperatorsTest/toString tests/DateTimeToString3",
"cql/CqlTypeOperatorsTest/As/AsQuantity",
"cql/CqlTypeOperatorsTest/As/CastAsQuantity",
"cql/CqlTypeOperatorsTest/Convert/StringToDateTimeMalformed",
"cql/CqlTypeOperatorsTest/Convert/StringToIntegerError",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeDate",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeMalformed",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeTimeUnspecified",
"cql/CqlTypeOperatorsTest/ToTime/ToTime2",
"cql/CqlTypeOperatorsTest/ToTime/ToTime3",
"cql/CqlTypeOperatorsTest/ToTime/ToTime4",
"cql/CqlTypeOperatorsTest/ToTime/ToTimeMalformed",
"cql/CqlTypesTest/DateTime/DateTimeUncertain",
"cql/CqlTypesTest/Time/TimeUpperBoundMillis",
"cql/ValueLiteralsAndSelectors/Boolean/BooleanFalse",
"cql/ValueLiteralsAndSelectors/Boolean/BooleanTrue",
"cql/ValueLiteralsAndSelectors/Decimal/Decimal10Pow20",
"cql/ValueLiteralsAndSelectors/Decimal/DecimalNeg10Pow20",
"cql/ValueLiteralsAndSelectors/Decimal/DecimalNegTenthStep",
"cql/ValueLiteralsAndSelectors/Decimal/DecimalPos10Pow20",
"cql/ValueLiteralsAndSelectors/Decimal/DecimalPosTenthStep",
"cql/ValueLiteralsAndSelectors/Decimal/DecimalTenthStep",
"cql/ValueLiteralsAndSelectors/Null/Null",
"r4/tests-fhir-r4/from-Zulip/(true and 'foo').empty()",
"r4/tests-fhir-r4/from-Zulip/(true | 'foo').allTrue()",
"r4/tests-fhir-r4/testAggregate/testAggregate1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ protected void runTest(
String outputExpression = test.getOutput().get(0).getValue();
if ("null".equals(outputExpression)) {
cql = String.format("%s (%s) is %s", cql, testExpression, outputExpression);
} else if ("null".equals(testExpression)) {
cql = String.format("%s (%s) is %s", cql, outputExpression, testExpression);
} else {
cql = String.format("%s (%s) = %s", cql, testExpression, outputExpression);
cql = String.format("%s (%s) = (%s)", cql, testExpression, outputExpression);
}
} else {
cql = String.format("%s %s", cql, testExpression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<output>'5'</output>
</test>
<test name="StringToIntegerError">
<expression invalid="true">convert 'foo' to Integer</expression>
<!-- EXPECT: Unable to convert given string to Integer -->
<expression>convert 'foo' to Integer</expression>
<output>null</output>
</test>
<test name="StringToDateTime">
<expression>convert '2014-01-01' to DateTime</expression>
Expand All @@ -37,8 +37,8 @@
<output>@T14:30:00.000</output>
</test>
<test name="StringToDateTimeMalformed">
<expression invalid="true">convert '2014/01/01' to DateTime</expression>
<!-- EXPECT: Invalid format: "2014/01/01" is malformed at "/01/01" -->
<expression>convert '2014/01/01' to DateTime</expression>
<output>null</output>
</test>
</group>
<group name="Is">
Expand Down Expand Up @@ -93,8 +93,8 @@
<output>@2014-01-01T12:05:05.955+00:00</output>
</test>
<test name="ToDateTimeMalformed">
<expression invalid="true">ToDateTime('2014/01/01T12:05:05.955Z')</expression>
<!-- EXPECT: Invalid format: "2014/01/01T12:05:05.955" is malformed at "/01/01T12:05:05.955" -->
<expression>ToDateTime('2014/01/01T12:05:05.955Z')</expression>
<output>null</output>
</test>
<test name="ToDateTimeDate">
<expression>ToDateTime(@2014-01-01)</expression>
Expand Down Expand Up @@ -159,8 +159,8 @@
<output>@T14:30:00.000</output>
</test>
<test name="ToTimeMalformed">
<expression invalid="true">ToTime('T14-30-00.0')</expression>
<!-- EXPECT: Invalid format: "T14-30-00.0" is malformed at "-30-00.0" -->
<expression>ToTime('T14-30-00.0')</expression>
<output>null</output>
</test>
</group>
</tests>

0 comments on commit ee6d3d7

Please sign in to comment.