You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2020/09/01 15:39:20 UTC

[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #409: Addressed Daffodil-2122 default="0|1" causes exception for xs:boolean…

mbeckerle commented on a change in pull request #409:
URL: https://github.com/apache/incubator-daffodil/pull/409#discussion_r481238000



##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section13/boolean/boolean.tdml
##########
@@ -0,0 +1,192 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<testSuite suiteName="Boolean"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" 
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:ex="http://example.com"
+  xmlns:tns="http://example.com"
+  defaultRoundTrip="onePass">
+  
+  <tdml:defineSchema name="BooleanDefaultSchema" elementFormDefault="unqualified">
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+    <dfdl:format ref="tns:GeneralFormat" separator=","
+                 initiator="" terminator="" leadingSkip='0' textTrimKind="none" initiatedContent="no"
+                 alignment="implicit" alignmentUnits="bits" trailingSkip="0" ignoreCase="no"
+                 separatorPosition="infix" occursCountKind="implicit" emptyValueDelimiterPolicy="both"
+                 representation="text" textNumberRep="standard" lengthKind="delimited" encoding="ASCII" />
+
+    <xs:element name="root1" dfdl:initiator="default1,default2,default3,default4%NL;%WSP*;">
+      <xs:complexType>
+        <xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="postfix">
+          <xs:element name="record" maxOccurs="unbounded">
+            <xs:complexType>
+                <xs:sequence dfdl:separator=','>
+                  <xs:element name="default1" type="xs:boolean" default="true" dfdl:textBooleanTrueRep="true" dfdl:textBooleanFalseRep="false" />
+                  <xs:element name="default2" type="xs:boolean" default="false" dfdl:textBooleanTrueRep="true" dfdl:textBooleanFalseRep="false" />
+                  <xs:element name="default3" type="xs:boolean" default="1" dfdl:textBooleanTrueRep="1" dfdl:textBooleanFalseRep="0" />
+                  <xs:element name="default4" type="xs:boolean" default="0" dfdl:textBooleanTrueRep="1" dfdl:textBooleanFalseRep="0" />
+                </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <!--
+  Test name: booleanDefault
+  Schema: BooleanDefaultSchema, root booleanDefault
+  Purpose: This test demonstrates parsing of valid boolean default values
+-->
+
+  <tdml:parserTestCase name="booleanDefault" root="root1"
+                       model="BooleanDefaultSchema"
+                       roundTrip="onePass"
+                       description="Test valid boolean default values.">
+    <tdml:document><![CDATA[default1,default2,default3,default4
+false,true,0,1
+]]></tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:root1>
+          <record>
+            <default1>false</default1>
+            <default2>true</default2>
+            <default3>false</default3>
+            <default4>true</default4>
+          </record>
+        </ex:root1>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:defineSchema name="BooleanDefaultSDE" elementFormDefault="unqualified">
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+    <dfdl:format ref="tns:GeneralFormat" separator=","
+                 initiator="" terminator="" leadingSkip='0' textTrimKind="none" initiatedContent="no"
+                 alignment="implicit" alignmentUnits="bits" trailingSkip="0" ignoreCase="no"
+                 separatorPosition="infix" occursCountKind="implicit" emptyValueDelimiterPolicy="both"
+                 representation="text" textNumberRep="standard" lengthKind="delimited" encoding="ASCII" />
+
+    <xs:element name="root1" dfdl:initiator="default1%NL;%WSP*;">
+      <xs:complexType>
+        <xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="postfix">
+          <xs:element name="record" maxOccurs="unbounded">
+            <xs:complexType>
+              <xs:sequence dfdl:separator=','>
+                <xs:element name="default1" type="xs:boolean" default="FALSE" dfdl:textBooleanTrueRep="TRUE" dfdl:textBooleanFalseRep="FALSE" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <!--
+  Test name: booleanDefaultSDE
+  Schema: BooleanDefaultSchemaSDE, root booleanDefault
+  Purpose: This test demonstrates parsing of invalid default values
+-->
+
+  <tdml:parserTestCase  name="booleanDefaultSDE" root="root1"
+                        model="BooleanDefaultSDE"
+                        description="Test SDE due to SAXParseException resulting from invalid default value">
+    <tdml:document><![CDATA[default1
+TRUE
+]]></tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>Invalid value constraint value</tdml:error>

Review comment:
       Is this test verifying that "FALSE" is not a legal default value for a boolean? Does the error message contain "FALSE" and the word "default" ? I think you should check for those here if possible.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org