Skip to content

Commit

Permalink
xml: update entity parse test (#21190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Apr 5, 2024
1 parent 254250d commit a7d68cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE body [
<!ENTITY warning "Warning: Something bad happened... please refresh and try again.">
]>
<body>
<message>
Warning: Something bad happened... please refresh and try again.
</message>
</body>
35 changes: 2 additions & 33 deletions vlib/encoding/xml/test/local/12_doctype_entity/spec_entity_test.v
Expand Up @@ -4,38 +4,7 @@ import os
import encoding.xml

fn test_valid_parsing() {
path := os.join_path(os.dir(@FILE), 'entity.xml')

mut reverse_entities := xml.default_entities_reverse.clone()
reverse_entities['Warning: Something bad happened... please refresh and try again.'] = 'warning'

expected := xml.XMLDocument{
parsed_reverse_entities: reverse_entities
doctype: xml.DocumentType{
name: 'body'
dtd: xml.DocumentTypeDefinition{
name: ''
list: [
xml.DTDEntity{
name: 'warning'
value: 'Warning: Something bad happened... please refresh and try again.'
},
]
}
}
root: xml.XMLNode{
name: 'body'
children: [
xml.XMLNode{
name: 'message'
children: [
'Warning: Something bad happened... please refresh and try again.',
]
},
]
}
}
actual := xml.XMLDocument.from_file(path)!.validate()!

expected := xml.XMLDocument.from_file(os.join_path(os.dir(@FILE), 'entity.xml'))!.validate()!
actual := xml.XMLDocument.from_file(os.join_path(os.dir(@FILE), 'entity_expected.xml'))!.validate()!
assert expected == actual, 'Parsed XML document should be equal to expected XML document'
}

0 comments on commit a7d68cb

Please sign in to comment.