| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | import encoding.xml |
| 5 | |
| 6 | fn test_valid_parsing() { |
| 7 | path := os.join_path(os.dir(@FILE), 'cdata.xml') |
| 8 | |
| 9 | expected := xml.XMLDocument{ |
| 10 | root: xml.XMLNode{ |
| 11 | name: 'sample' |
| 12 | children: [ |
| 13 | xml.XMLNode{ |
| 14 | name: 'html' |
| 15 | children: ['This is <b>bold</b>'] |
| 16 | }, |
| 17 | xml.XMLNode{ |
| 18 | name: 'html' |
| 19 | children: [xml.XMLCData{ |
| 20 | text: 'This is <b>bold</b>' |
| 21 | }] |
| 22 | }, |
| 23 | ] |
| 24 | } |
| 25 | } |
| 26 | actual := xml.XMLDocument.from_file(path)! |
| 27 | |
| 28 | assert expected == actual, 'Parsed XML document should be equal to expected XML document' |
| 29 | } |
| 30 | |