| 1 | import os |
| 2 | import encoding.xml |
| 3 | |
| 4 | fn 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 | |