From 0f4356ce721135cf9bad07fcb61c3fca5ab067f3 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Sun, 17 Nov 2024 21:51:57 +0530 Subject: [PATCH] Add toxml test for choice with element annotations --- ...choice_test_with_element_annotation_with_parse_type.bal | 7 ++++++- .../tests/xsd_sequence_array_test_with_parse_type.bal | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ballerina/tests/xsd_choice_test_with_element_annotation_with_parse_type.bal b/ballerina/tests/xsd_choice_test_with_element_annotation_with_parse_type.bal index 89268ea..52439e0 100644 --- a/ballerina/tests/xsd_choice_test_with_element_annotation_with_parse_type.bal +++ b/ballerina/tests/xsd_choice_test_with_element_annotation_with_parse_type.bal @@ -32,7 +32,6 @@ function testXsdChoiceWithElementAnnotationWithXmlValue() returns error? { xmlValue = xml `ABC`; v = parseAsType(xmlValue); test:assertEquals(v, {"seq_EA1":{"EA2": "ABC"}}); - // TODO: Empty element test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABABABABAB`; @@ -43,6 +42,7 @@ function testXsdChoiceWithElementAnnotationWithXmlValue() returns error? { xmlValue = xml `ABAB`; v = parseAsType(xmlValue); test:assertEquals(v, {"seq_EA1":{EA3: ["AB", "AB"]}}); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABABABABABAB`; v = parseAsType(xmlValue); @@ -61,6 +61,7 @@ function testXsdChoiceWithElementAnnotationWithXmlValue() returns error? { xmlValue = xml `ABC`; v = parseAsType(xmlValue); test:assertEquals(v, {seq_EA1: {EA1: ["ABC"]}}); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABCAB`; v = parseAsType(xmlValue); @@ -113,18 +114,22 @@ function testXsdChoiceWithElementAnnotationWithXmlValue2() returns error? { v = parseAsType(xmlValue); test:assertEquals(v, {seq_EA2: {EA: {EA1: "ABC", EA2: "ABC", EA3: ["AB", "CD"]}}}); test:assertEquals(toXml(check v), xmlValue); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABCABAB`; v = parseAsType(xmlValue); test:assertEquals(v, {"seq_EA2": {EA: {"EA2": "ABC", EA3: ["AB", "AB"]}}}); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABCABAB`; v = parseAsType(xmlValue); test:assertEquals(v, {"seq_EA2": {EA: {"EA2": "ABC", EA3: ["AB", "AB"]}}}); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABAB`; v = parseAsType(xmlValue); test:assertEquals(v, {"seq_EA2": {EA: {EA3: ["AB", "AB"]}}}); + test:assertEquals(toXml(check v), xmlValue); xmlValue = xml `ABABABABABAB`; v = parseAsType(xmlValue); diff --git a/ballerina/tests/xsd_sequence_array_test_with_parse_type.bal b/ballerina/tests/xsd_sequence_array_test_with_parse_type.bal index f4e891f..f85b540 100644 --- a/ballerina/tests/xsd_sequence_array_test_with_parse_type.bal +++ b/ballerina/tests/xsd_sequence_array_test_with_parse_type.bal @@ -176,9 +176,12 @@ function testXSDSequenceArrayWithXmlValueRecord4() returns error? { v2 = parseAsType(xmlValue); test:assertTrue(v2 is Error); test:assertEquals((v2).message(), "'value3' occurs more than the max allowed times"); +} - xmlValue = xml `123123123123123123123`; - v2 = parseAsType(xmlValue); +@test:Config {groups: ["xsd", "xsd_sequence"]} +function testXSDSequenceArrayWithXmlValueRecord4P2() returns error? { + xml xmlValue = xml `123123123123123123123`; + XSDSequenceArrayWithXmlValueRecord13|Error v2 = parseAsType(xmlValue); test:assertTrue(v2 is Error); test:assertEquals((v2).message(), "Element(s) 'field6' is not found in 'seq_XSDSequenceArrayWithXmlValueRecord13_2'");