| 1 | import net.html |
| 2 | |
| 3 | fn test_nil() { |
| 4 | mut doc := |
| 5 | html.parse('<body><div class="Box-footer"><div class="truncate">abc</div></div></body>') |
| 6 | footer := doc.get_tags_by_class_name('Box-footer')[0] |
| 7 | hrefs := footer.get_tag_by_class_name('Truncate') |
| 8 | println(hrefs) |
| 9 | res := '${hrefs}' |
| 10 | assert res == '&Option(&nil)' |
| 11 | } |
| 12 | |
| 13 | fn test_non_nil() { |
| 14 | mut doc := |
| 15 | html.parse('<body><div class="Box-footer"><div class="Truncate">abc</div></div></body>') |
| 16 | footer := doc.get_tags_by_class_name('Box-footer')[0] |
| 17 | hrefs := footer.get_tag_by_class_name('Truncate') |
| 18 | println(hrefs) |
| 19 | res := '${hrefs}' |
| 20 | assert res == '&Option(<div class="Truncate" >abc</div>)' |
| 21 | } |
| 22 | |