Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml: update entity parse test #21190

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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'
}