v / vlib / encoding / xml / test / local / 08_comments / comment_test.v
42 lines · 39 sloc · 868 bytes · acf6b344f733169ec6ecc9881f8a8c2c795b9883
Raw
1import os
2import encoding.xml
3
4fn test_valid_parsing() ! {
5 path := os.join_path(os.dir(@FILE), 'comment.xml')
6
7 expected := xml.XMLDocument{
8 comments: [
9 xml.XMLComment{
10 text: ' Employee Information'
11 },
12 ]
13 root: xml.XMLNode{
14 name: 'address'
15 children: [
16 xml.XMLComment{
17 text: ' Full or first name '
18 },
19 xml.XMLNode{
20 name: 'name'
21 children: ['Jones']
22 },
23 xml.XMLComment{
24 text: ' Registered name of the company -> '
25 },
26 xml.XMLNode{
27 name: 'company'
28 children: ['ABSystems']
29 },
30 xml.XMLNode{
31 name: 'phone'
32 children: [xml.XMLComment{
33 text: ' Phone with country code -) '
34 }, '(046) 1233-44778']
35 },
36 ]
37 }
38 }
39 actual := xml.XMLDocument.from_file(path)!
40
41 assert expected == actual, 'Parsed XML document should be equal to expected XML document'
42}
43