You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2020/09/14 12:36:39 UTC
[incubator-daffodil] 02/03: Update per Steve's comments
This is an automated email from the ASF dual-hosted git repository.
slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
commit 8eae1c21b3a96a07035af9cb6669ebfc6e59da9a
Author: Steinberger <rs...@tresys.com>
AuthorDate: Fri Sep 11 12:35:53 2020 -0400
Update per Steve's comments
Reconfigured the test
Update the if statement
---
.../org/apache/daffodil/dsom/ChoiceGroup.scala | 2 +-
.../daffodil/section15/choice_groups/choice.tdml | 54 +++++++++++-----------
.../section15/choice_groups/TestChoice.scala | 2 +
3 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
index ec88686..410d235 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ChoiceGroup.scala
@@ -203,7 +203,7 @@ abstract class ChoiceTermBase(
}.value
final lazy val noBranchesFound = LV('noBranchesFound) {
- if(groupMembers.size.equals(0)) {
+ if (groupMembers.size == 0) {
SDE("choice element must contain one or more branches")
}
}.value
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
index e29e7ff..b9a8f5d 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section15/choice_groups/choice.tdml
@@ -52,6 +52,18 @@
</xs:complexType>
</xs:element>
+ <xs:element name="ch2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="redOrBlue" minOccurs="0" dfdl:occursCountKind="implicit">
+ <xs:complexType>
+ <xs:choice>
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
</tdml:defineSchema>
@@ -71,6 +83,20 @@
</tdml:parserTestCase>
+ <!--
+ Test Name: choice_noBranch
+ Schema: basic
+ Purpose: This test demonstrates the SDE where you have a choice with no branches.
+ -->
+
+ <tdml:parserTestCase name="choice_noBranch" root="ch2"
+ model="basic">
+ <tdml:document>red</tdml:document>
+ <tdml:errors>
+ <tdml:error>Schema Definition Error</tdml:error>
+ <tdml:error>choice element must contain one or more branches</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
<tdml:defineSchema name="choice2">
<xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
@@ -1336,19 +1362,6 @@
</xs:sequence>
</xs:complexType>
- <xs:element name="e0">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="redOrBlue" minOccurs="0" dfdl:occursCountKind="implicit">
- <xs:complexType>
- <xs:choice>
- </xs:choice>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
<xs:element name="e1">
<xs:complexType>
<xs:sequence dfdl:separator="/%NL;" dfdl:separatorPosition="postfix" dfdl:separatorSuppressionPolicy="trailingEmptyStrict">
@@ -1400,21 +1413,6 @@
</tdml:defineSchema>
<!--
- Test Name: optionalChoice0
- Schema: optionalChoices
- Purpose: This test demonstrates the SDE where you have a choice with no branches.
- -->
-
- <tdml:parserTestCase name="optionalChoice00" root="e0"
- model="optionalChoices">
- <tdml:document>red</tdml:document>
- <tdml:errors>
- <tdml:error>Schema Definition Error</tdml:error>
- <tdml:error>choice element must contain one or more branches</tdml:error>
- </tdml:errors>
- </tdml:parserTestCase>
-
- <!--
Test Name: optionalChoice01
Schema: optionalChoices
Purpose: This test demonstrates the scenario where you have a choice of two initiated elements in an optional choice. In this case the first element should be selected.
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
index 97dae26..44ac031 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section15/choice_groups/TestChoice.scala
@@ -38,6 +38,8 @@ class TestChoice {
import TestChoice._
+ @Test def test_choice_noBranch (): Unit = { runnerCH.runOneTest("choice_noBranch") }
+
@Test def test_optionalChoice00(): Unit = { runnerCH.runOneTest("optionalChoice00") }
@Test def test_optionalChoice01(): Unit = { runnerCH.runOneTest("optionalChoice01") }
@Test def test_optionalChoice02(): Unit = { runnerCH.runOneTest("optionalChoice02") }