xml: update entity parse test (#21190)

This commit is contained in:
Turiiya 2024-04-05 16:31:32 +02:00 committed by GitHub
parent 254250d375
commit a7d68cbc2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 33 deletions

View file

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

View file

@ -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'
}