| 1 | import os |
| 2 | import encoding.xml |
| 3 | |
| 4 | fn test_valid_parsing() ! { |
| 5 | path := os.join_path(os.dir(@FILE), 'mixed.xml') |
| 6 | |
| 7 | expected := xml.XMLDocument{ |
| 8 | root: xml.XMLNode{ |
| 9 | name: 'letter' |
| 10 | children: [ |
| 11 | 'Dear Mr.', |
| 12 | xml.XMLNode{ |
| 13 | name: 'name' |
| 14 | children: ['John Smith'] |
| 15 | }, |
| 16 | '.\n Your order', |
| 17 | xml.XMLNode{ |
| 18 | name: 'orderid' |
| 19 | children: ['1032'] |
| 20 | }, |
| 21 | 'will be shipped on', |
| 22 | xml.XMLNode{ |
| 23 | name: 'shipdate' |
| 24 | children: ['2001-07-13'] |
| 25 | }, |
| 26 | '.', |
| 27 | ] |
| 28 | } |
| 29 | } |
| 30 | actual := xml.XMLDocument.from_file(path)! |
| 31 | |
| 32 | assert expected == actual, 'Parsed XML document should be equal to expected XML document' |
| 33 | } |
| 34 | |