oxedyne/fe2o3/fe2o3_text/tests/html_reference.rs
746 bytes, 1 run
created by r2430630900:78613, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! One character reference read, and the entity decoder that reads through it. |
| 2 | |
| 3 | use oxedyne_fe2o3_text::html::{ |
| 4 | decode_entities, |
| 5 | reference, |
| 6 | }; |
| 7 | |
| 8 | #[test] |
| 9 | fn a_reference_is_read_with_its_length() { |
| 10 | assert_eq!(reference("é x"), Some((8, String::from("\u{e9}")))); |
| 11 | assert_eq!(reference("A"), Some((6, String::from("A")))); |
| 12 | assert_eq!(reference("&nosuch; x"), None); |
| 13 | assert_eq!(reference("& x"), None); |
| 14 | } |
| 15 | |
| 16 | /// An `&` before a reference is text, and the reference after it still reads, as a browser |
| 17 | /// reads it (was `&&`). |
| 18 | #[test] |
| 19 | fn an_ampersand_before_a_reference_leaves_it_read() { |
| 20 | assert_eq!(decode_entities("&&"), "&&"); |
| 21 | assert_eq!(decode_entities("a &nosuch; &lt;"), "a &nosuch; <"); |
| 22 | } |