| 1 | import os |
| 2 | import encoding.xml |
| 3 | |
| 4 | fn test_valid_parsing() ! { |
| 5 | path := os.join_path(os.dir(@FILE), 'note.xml') |
| 6 | |
| 7 | expected := xml.XMLDocument{ |
| 8 | root: xml.XMLNode{ |
| 9 | name: 'note' |
| 10 | children: [ |
| 11 | xml.XMLNode{ |
| 12 | name: 'to' |
| 13 | children: [ |
| 14 | 'Tove', |
| 15 | ] |
| 16 | }, |
| 17 | xml.XMLNode{ |
| 18 | name: 'from' |
| 19 | children: [ |
| 20 | 'Jani', |
| 21 | ] |
| 22 | }, |
| 23 | xml.XMLNode{ |
| 24 | name: 'heading' |
| 25 | children: [ |
| 26 | 'Reminder', |
| 27 | ] |
| 28 | }, |
| 29 | xml.XMLNode{ |
| 30 | name: 'body' |
| 31 | children: [ |
| 32 | "Don't forget me this weekend!", |
| 33 | ] |
| 34 | }, |
| 35 | ] |
| 36 | } |
| 37 | } |
| 38 | actual := xml.XMLDocument.from_file(path)! |
| 39 | |
| 40 | assert expected == actual, 'Parsed XML document should be equal to expected XML document' |
| 41 | } |
| 42 | |