stevedlawrence commented on code in PR #1185:
URL: https://github.com/apache/daffodil/pull/1185#discussion_r1526540195


##########
daffodil-test/src/test/resources/org/apache/daffodil/section00/general/tunables.tdml:
##########
@@ -811,4 +832,78 @@
 
   </tdml:unparserTestCase>
 
+  <tdml:defineSchema name="intPatternRestriction">
+    <xs:include 
schemaLocation="/org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+    <dfdl:format ref="ex:GeneralFormat" lengthKind="delimited" />
+
+    <xs:element name="int">
+      <xs:simpleType>
+        <xs:restriction base="xs:int">
+          <xs:pattern value=".*[05]" /> <!-- must be a multiple of 5 -->
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <tdml:parserTestCase
+    name="invalidRestrictionPolicyError_01" root="int"
+    model="intPatternRestriction"
+    config="cfg_invalidRestrictionPolicyError"
+    validation="limited">
+    <tdml:document>201</tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>Pattern restriction</tdml:error>
+      <tdml:error>string</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase
+    name="invalidRestrictionPolicyIgnore_01" root="int"
+    model="intPatternRestriction"
+    config="cfg_invalidRestrictionPolicyIgnore"
+    validation="limited">
+    <tdml:document>201</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:int>201</ex:int>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+    <tdml:validationErrors /> <!-- there should be no validation errors -->
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase
+    name="invalidRestrictionPolicyValidate_01" root="int"
+    model="intPatternRestriction"
+    config="cfg_invalidRestrictionPolicyValidate"
+    validation="limited">
+    <tdml:document>201</tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:int>201</ex:int>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+    <tdml:validationErrors>
+      <tdml:error>failed facet checks</tdml:error>
+      <tdml:error>pattern</tdml:error>
+      <tdml:error>.*[05]</tdml:error>
+    </tdml:validationErrors>

Review Comment:
   Mentioned above, but validation errors are ignored if there is no 
`<tdml:validationErrors>` element, so with those lines removed this test would 
still pass but would not verify that validation occurred.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to